读书人

技术误区啊

发布时间: 2013-03-25 15:43:04 作者: rapoo

技术误区啊。。。。。。。。。。

@JSON(serialize=false)
??? public String updateStatu() throws Exception {
??? ??? BigDecimal percent=new BigDecimal(0);
??? ??? String loginName = super.getLoginUsername();
??? ??? if(loginName == null || loginName.length()==0)
??? ??? {
??? ??? ??? return "login";
??? ??? }else {
??? ??? User user=this.getUserService().select(loginName);
??? ??? BuyCart buyCart=(BuyCart)ActionContext.getContext().getSession().get("cart");
??? ??? buyCart.getBuyCartDeal().setUser(user);
??? ??? buyCart.getBuyCartDeal().setTotalMoney(Double.valueOf(buyCart.getTotalPrice().toString()));
??? ??? Set<String> keySet = buyCart.getShopCartMap().keySet();
??? ??? for(String key : keySet){
??? ??? ??? buyCart.getBuyCartDeal().getBuyCommoditiesSet().add(buyCart.getShopCartMap().get(key))??? ; ???
??? ??? }
??? ??? Account account=this.getAccountService().select(user.getId(), "");
??? ??? SiteConfig siteConfig=this.getSiteConfigService().getCurrentSiteConfig();
??? ??? if (buyCart.getTotalPrice()>Integer.valueOf(account.getRemainingMoney().toString())) {
??? ??? ??? this.trademsg="fail";
??? ??? ??? buyCart.getBuyCartDeal().setStatus(4);
??? ??? ??? buyCart.getBuyCartDeal().setDeliveryTime(getcurrent());
??? ??? ??? String res=buyCartDealService.insert(buyCart.getBuyCartDeal());
??? ??? ??? if (res==null) {
??? ??? ??? ??? this.trademsg="not";
??? ??? ??? }
??? ??? }else {
??? ??? ??? buyCart.getBuyCartDeal().setDeliveryTime(getcurrent());
??? ??? ??? String res=buyCartDealService.insert(buyCart.getBuyCartDeal());
??? ??? ??? //如果可以操作,将购买图片的用户的余额扣除
??? ??? ??? Account account22=this.getAccountService().select(user.getId(),"");
??? ??? ??? BigDecimal bigdecimal=new BigDecimal(buyCart.getBuyCartDeal().getTotalMoney());
??? ??? ??? account22.setRemainingMoney(account22.getRemainingMoney().subtract(bigdecimal));
??? ??? ??? this.getAccountService().update(account22);
??? ??? ??? account22.setTotalMoney(account22.getRemainingMoney());
??? ??? ??? this.getAccountService().update(account22);
??? ??? ???
??? ??? ??? BigDecimal bigDecimalTax=new BigDecimal(buyCart.getBuyCartDeal().getTotalMoney()*siteConfig.getTax());
??? ??? ??? BigDecimal bigDecimalBroker=new BigDecimal(buyCart.getBuyCartDeal().getTotalMoney()*0.1);
??? ??? ??? BigDecimal bigDecimalThird=new BigDecimal(buyCart.getBuyCartDeal().getTotalMoney()*siteConfig.getThirdPayRate());
??? ??? ??? BigDecimal adminMoney=bigDecimalTax.add(bigDecimalBroker.add(bigDecimalThird));//需要给网站管理员的扣费
//??? ??? ???
//??? ??? ??? BigDecimal bigDecimaltotal=new BigDecimal(buyCart.getBuyCartDeal().getTotalMoney());
//??? ??? ??? BigDecimal totalRemain=bigDecimaltotal.subtract(adminMoney);//商品的总价格扣除管理员扣费后的价格
??? ??? ??? Account account3=this.accountService.select(3,"");
??? ??? ??? account3.setRemainingMoney(account3.getRemainingMoney().add(adminMoney));
??? ??? ??? accountService.update(account3);
??? ??? ??? account3.setTotalMoney(account3.getRemainingMoney());
??? ??? ??? accountService.update(account3);//管理员应得
??? ??? ??? Map<String, BigDecimal> percent1=new HashMap<String, BigDecimal>();
??? ??? ??? BigDecimal sum=new BigDecimal(buyCart.getBuyCartDeal().getTotalMoney());
??? ??? ??? //给发布图片的用户分钱
??? ??? ??? for (BuyCommodities buyCommodities:buyCart.getBuyCartDeal().getBuyCommoditiesSet()) {
??? ??? ??? ??? buyCommodities.setBuyCartDeal(buyCart.getBuyCartDeal());
??? ??? ??? ??? ??????? Publish publish=buyCommodities.getPublish();
??? ??? ??? ??? ??????? if (buyCommodities.getCopyrightOrUsage()==0) {
??? ??? ??? ??? ??????? ??? BigDecimal usgeBigDecimal=new BigDecimal(buyCommodities.getUsgeTotalPrice());
??? ??? ??? ??? ??????? ??? BigDecimal usgePersent=usgeBigDecimal.divide(sum);
??? ??? ??? ??? ??????? ??? percent1.put(publish.getUser().getId()+"",usgePersent);
??? ??? ??? ??? ??? ??? }else if (buyCommodities.getCopyrightOrUsage()==1) {
??? ??? ??? ??? ??? ??? ??? BigDecimal copy=new BigDecimal(buyCommodities.getCopyrighTotalPrice());
??? ??? ??? ??? ??? ??? ??? percent1.put(publish.getUser().getId()+"",copy.divide(sum));
??? ??? ??? ??? ??? ??? }else if (buyCommodities.getCopyrightOrUsage()==2) {
??? ??? ??? ??? ??? ??? ??? BigDecimal total=new BigDecimal(buyCommodities.getCopyAndUsePrice());
??? ??? ??? ??? ??? ??? ??? percent1.put(publish.getUser().getId()+"",total.divide(sum));
??? ??? ??? ??? ??? ??? }
??? ??? ??? ??? buyCommoditiesService.insert(buyCommodities);
//??? ??? ??? ??? User user2=buyCommodities.getPublish().getUser();
//??? ??? ??? ??? Account account2=this.getAccountService().select(user2.getId(),"");
//??? ??? ??? ??? if (buyCommodities.getCopyrightOrUsage()==0) {
//??? ??? ??? ??? ??? BigDecimal bigDecimal0=new BigDecimal(buyCommodities.getPublish().getUsagePrice());
//??? ??? ??? ??? ??? account2.setRemainingMoney(account2.getRemainingMoney().add(bigDecimal0));
//??? ??? ??? ??? }
//??? ??? ??? ??? if (buyCommodities.getCopyrightOrUsage()==1) {
//??? ??? ??? ??? ??? //BigDecimal bigDecimal1=new BigDecimal(buyCommodities.getPublish().getUsagePrice());
//??? ??? ??? ??? ??? BigDecimal bigDecimal4=new BigDecimal(buyCommodities.getPublish().getCopyrightPrice());
//??? ??? ??? ??? ??? account2.setRemainingMoney(account2.getRemainingMoney().add(bigDecimal4));
//??? ??? ??? ??? ??? }
//??? ??? ??? ??? if (buyCommodities.getCopyrightOrUsage()==2) {
//??? ??? ??? ??? ??? BigDecimal bigDecimal12=new BigDecimal(buyCommodities.getPublish().getCopyrightPrice()+buyCommodities.getPublish().getUsagePrice());
//??? ??? ??? ??? ??? account2.setRemainingMoney(account2.getRemainingMoney().add(bigDecimal12));
//??? ??? ??? ??? }
//??? ??? ??? ??? accountService.update(account2);
//??? ??? ??? ??? account2.setTotalMoney(account2.getRemainingMoney());
//??? ??? ??? ??? accountService.update(account2);
??? ??? ??? ???
??? ??? ??? }
??? ??? ???
??? ??? ??? List<Account> list=new ArrayList<Account>();
??? ??? ??? list.add(account22);
??? ??? ??? list.add(account3);
??? ??? ??? Set<String> Uid=percent1.keySet();
??? ??? ??? Iterator iterator=Uid.iterator();
??? ??? ??? BigDecimal tx=new BigDecimal(siteConfig.getTax());
??? ??? ??? BigDecimal third=new BigDecimal(siteConfig.getThirdPayRate());
??? ??? ??? BigDecimal tax=sum.multiply(tx);
??? ??? ??? BigDecimal td=sum.multiply(third);
??? ??? ??? BigDecimal broker=sum.multiply(new BigDecimal(0.15));
??? ??? ??? sum=sum.subtract((tax.add(td.add(broker))));
??? ??? ??? while (iterator.hasNext()) {
??? ??? ??? ??? String key=(String)iterator.next();
??? ??? ??? ??? BigDecimal per=percent1.get(key);
??? ??? ??? ??? sum=sum.multiply(per);
??? ??? ??? ??? Account account2=this.getAccountService().select(Integer.valueOf(key),"");
??? ??? ??? ??? account2.setRemainingMoney(sum.add(account2.getRemainingMoney()));
??? ??? ??? ??? accountService.update(account2);
??? ??? ??? ??? account2.setTotalMoney(account2.getTotalMoney().add(account2.getRemainingMoney()));
??? ??? ??? ??? accountService.update(account2);
??? ??? ??? ??? list.add(account2);
??? ??? ??? }
??? ??? ??? buyCart.getBuyCartDeal().setStatus(5);
??? ??? ??? buyCart.getBuyCartDeal().setDeliveryTime(getcurrent());
??? ??? ??? buyCartDealService.update(buyCart.getBuyCartDeal());
??? ??? ??? buyCartDealService.dealCart(list);
??? ??? ??? this.trademsg="suc";
??? ??? ???
??? ??? }
??? ??? }
??? ??? return "updateStatu";
??? }

读书人网 >行业软件

热点推荐