easyui简易提交订单,前台页面

![主界面,上下布局,easyui简易提交订单,前台页面_第1张图片


<%@ page contentType="text/html;charset=UTF-8" language="java" %>


    Title
    


客户: *
成交时间: * 订单金额: *
订单状态: * 优惠金额: *
支付方式: * 金额总计: *
备注:
客户: 查询
``

serviced层代码
public int insert(Order order, String goodIds) {
int i=orderMapper.insert(order);
if(goodIds!=null&&!"".equals(goodIds)){
String[] split = goodIds.split(",");
for (String id : split) {

            Type type = typeMapper.selectByPrimaryKey(new BigDecimal(id));
            if(type.getGoodsPrice().compareTo(order.getTotalMoney())==1){
                return 0;
            }
            OrderGoodsExample example = new OrderGoodsExample();
            example.createCriteria().andGoodNameEqualTo(type.getGoodName());
            List list =orderGoodsMapper.selectByExample(example);
            if(list.isEmpty()){
                BigDecimal divide = order.getTotalMoney().divide(type.getGoodsPrice(),2,BigDecimal.ROUND_HALF_DOWN);
                OrderGoods orderGoods = new OrderGoods();
                orderGoods.setOrderId(order.getId());
                orderGoods.setGoodName(type.getGoodName());
                orderGoods.setGoodsPrice(type.getGoodsPrice());
                orderGoods.setGoodsSpec(type.getGoodsSpec());
                orderGoods.setGoodsUnit(type.getGoodsUnit());
                orderGoods.setGoodsCount(divide);
                orderGoodsMapper.insert(orderGoods);
            }else{

                BigDecimal divide = order.getTotalMoney().divide(type.getGoodsPrice(),2,BigDecimal.ROUND_HALF_DOWN);
                OrderGoods orderGoods=list.get(0);
                orderGoods.setGoodsCount(divide.add(orderGoods.getGoodsCount()));
                orderGoodsMapper.updateByPrimaryKeySelective(orderGoods);
            }
        }
        return 1;
    }return 0;
}

你可能感兴趣的:(easyui添加订单,不同的数据表中)