Bladeren bron

新增订单碳汇量来源

赵冬冬 4 jaren geleden
bovenliggende
commit
14b4d90757
14 gewijzigde bestanden met toevoegingen van 2063 en 149 verwijderingen
  1. 160 0
      carbon-h5/carbon-h5-common/src/main/java/com/hcloud/microserver/facade/carbon/entity/CustomerCarbonVal.java
  2. 1122 0
      carbon-h5/carbon-h5-common/src/main/java/com/hcloud/microserver/facade/carbon/entity/CustomerCarbonValExample.java
  3. 17 0
      carbon-h5/carbon-h5-common/src/main/java/com/hcloud/microserver/facade/carbon/entity/from/CreateOrderDetailFrom.java
  4. 18 0
      carbon-h5/carbon-h5-common/src/main/java/com/hcloud/microserver/facade/carbon/entity/from/CreateOrderFrom.java
  5. 5 0
      carbon-h5/carbon-h5-common/src/main/java/com/hcloud/microserver/facade/carbon/forms/GoodsOrderDetailForm.java
  6. 20 21
      carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/controller/web/OrderManagerController.java
  7. 1 3
      carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/controller/web/WechatAppController.java
  8. 31 0
      carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/dao/CustomerCarbonValMapper.java
  9. 1 1
      carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/entity/LoginRequest.java
  10. 2 0
      carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/service/OrderInfoService.java
  11. 288 118
      carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/service/impl/OrderInfoServiceImpl.java
  12. 353 0
      carbon-h5/carbon-h5-service/src/main/resources/com/hcloud/microserver/h5/dao/CustomerCarbonValMapper.xml
  13. 26 6
      carbon-h5/carbon-h5-service/src/main/resources/com/hcloud/microserver/h5/dao/GoodsOrderDetailMapper.xml
  14. 19 0
      common-core/src/main/java/com/hcloud/microserver/commoncore/base/BaseController.java

+ 160 - 0
carbon-h5/carbon-h5-common/src/main/java/com/hcloud/microserver/facade/carbon/entity/CustomerCarbonVal.java

@@ -0,0 +1,160 @@
+package com.hcloud.microserver.facade.carbon.entity;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+public class CustomerCarbonVal {
+    /** 序列*/
+    private String guid;
+
+    /** 用户id*/
+    private String tCustomerId;
+
+    /** 用户名称*/
+    private String tCustomerName;
+
+    /** 购买碳汇量*/
+    private BigDecimal carbonVal;
+
+    /** 状态 1 新增 0 减去*/
+    private Integer status;
+
+    /** 类型 1购买碳汇 2企业碳中和 3大型活动碳中和 4碳履约*/
+    private Integer type;
+
+    /** 来源表id*/
+    private String tbGuid;
+
+    /** 表名称*/
+    private String tbName;
+
+    /** 来源明细*/
+    private String remarks;
+
+    /** 年份*/
+    private Integer yearTime;
+
+    /** 创建人*/
+    private String createUser;
+
+    /** 创建时间*/
+    private Date createTime;
+
+    /** 更新人*/
+    private String updateUser;
+
+    /** 更新时间*/
+    private Date updateTime;
+
+    public String getGuid() {
+        return guid;
+    }
+
+    public void setGuid(String guid) {
+        this.guid = guid == null ? null : guid.trim();
+    }
+
+    public String gettCustomerId() {
+        return tCustomerId;
+    }
+
+    public void settCustomerId(String tCustomerId) {
+        this.tCustomerId = tCustomerId == null ? null : tCustomerId.trim();
+    }
+
+    public String gettCustomerName() {
+        return tCustomerName;
+    }
+
+    public void settCustomerName(String tCustomerName) {
+        this.tCustomerName = tCustomerName == null ? null : tCustomerName.trim();
+    }
+
+    public BigDecimal getCarbonVal() {
+        return carbonVal;
+    }
+
+    public void setCarbonVal(BigDecimal carbonVal) {
+        this.carbonVal = carbonVal;
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    public Integer getType() {
+        return type;
+    }
+
+    public void setType(Integer type) {
+        this.type = type;
+    }
+
+    public String getTbGuid() {
+        return tbGuid;
+    }
+
+    public void setTbGuid(String tbGuid) {
+        this.tbGuid = tbGuid == null ? null : tbGuid.trim();
+    }
+
+    public String getTbName() {
+        return tbName;
+    }
+
+    public void setTbName(String tbName) {
+        this.tbName = tbName == null ? null : tbName.trim();
+    }
+
+    public String getRemarks() {
+        return remarks;
+    }
+
+    public void setRemarks(String remarks) {
+        this.remarks = remarks == null ? null : remarks.trim();
+    }
+
+    public Integer getYearTime() {
+        return yearTime;
+    }
+
+    public void setYearTime(Integer yearTime) {
+        this.yearTime = yearTime;
+    }
+
+    public String getCreateUser() {
+        return createUser;
+    }
+
+    public void setCreateUser(String createUser) {
+        this.createUser = createUser == null ? null : createUser.trim();
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getUpdateUser() {
+        return updateUser;
+    }
+
+    public void setUpdateUser(String updateUser) {
+        this.updateUser = updateUser == null ? null : updateUser.trim();
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+}

File diff suppressed because it is too large
+ 1122 - 0
carbon-h5/carbon-h5-common/src/main/java/com/hcloud/microserver/facade/carbon/entity/CustomerCarbonValExample.java


+ 17 - 0
carbon-h5/carbon-h5-common/src/main/java/com/hcloud/microserver/facade/carbon/entity/from/CreateOrderDetailFrom.java

@@ -0,0 +1,17 @@
+package com.hcloud.microserver.facade.carbon.entity.from;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class CreateOrderDetailFrom {
+    /**
+     * 商品id
+     */
+    private String goodsId;
+    /**
+     * 碳汇量
+     */
+    private BigDecimal carbonVal;
+}

+ 18 - 0
carbon-h5/carbon-h5-common/src/main/java/com/hcloud/microserver/facade/carbon/entity/from/CreateOrderFrom.java

@@ -0,0 +1,18 @@
+package com.hcloud.microserver.facade.carbon.entity.from;
+
+import com.hcloud.microserver.facade.carbon.entity.GoodsOrderInfo;
+import lombok.Data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Data
+public class CreateOrderFrom {
+//    /**
+//     * 登陆人id
+//     */
+//    private String fkCustomerGuid;
+
+    List<CreateOrderDetailFrom> goods = new ArrayList();
+
+}

+ 5 - 0
carbon-h5/carbon-h5-common/src/main/java/com/hcloud/microserver/facade/carbon/forms/GoodsOrderDetailForm.java

@@ -24,6 +24,11 @@ public class GoodsOrderDetailForm extends BaseForm {
     private BigDecimal saleNum;
 
     private BigDecimal amount;
+    /**
+     * 碳汇量
+     */
+    private BigDecimal carbonVal;
+
 
     /**
      * 商品编号

+ 20 - 21
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/controller/web/OrderManagerController.java

@@ -2,6 +2,7 @@ package com.hcloud.microserver.h5.controller.web;
 
 import com.github.pagehelper.PageInfo;
 import com.google.common.collect.Lists;
+import com.hcloud.microserver.facade.carbon.entity.from.CreateOrderFrom;
 import com.hcloud.microserver.h5.bo.CredentialInfoBO;
 import com.hcloud.microserver.h5.bo.OrderInfoBO;
 import com.hcloud.microserver.h5.common.BaseInfoDO;
@@ -38,8 +39,6 @@ public class OrderManagerController extends CarbonBaseController {
     @Autowired
     private OrderInfoService orderInfoService;
 
-    @Autowired
-    private OrderPayService orderPayApplyClient;
 
     @Autowired
     private OrderDetailInfoService orderDetailInfoService;
@@ -60,6 +59,21 @@ public class OrderManagerController extends CarbonBaseController {
     private OrderPayApplyService orderPayApplyService;
 
 
+    @ApiOperation(value = "生成订单信息", notes = "生成订单信息")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "orderId", value = "订单Id", dataType = "String")
+    })
+    @ApiResponse(code = 0, message = "操作成功")
+    @PostMapping("/createOrder")
+    @AuthCarbonValidate
+    public ResponseBase createOrder(@RequestBody CreateOrderFrom createOrderFrom) {
+
+        orderInfoService.createOrder(createOrderFrom);
+        return resultVOSuccess();
+    }
+
+
+
     @ApiOperation(value = "查询爱心用户订单信息", notes = "分类查询爱心用户订单")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "orderType", value = "爱心用户信息", dataType = "Integer", paramType = "query")
@@ -148,31 +162,16 @@ public class OrderManagerController extends CarbonBaseController {
         return responseError(resultVO);
     }
 
-    @Autowired
-    private RedissonClient redissonClient;
+
+
     //商品秒杀核心业务逻辑的处理-redisson的分布式锁
 
     public ResultVO saveOrderInfoAndPayOrderInfo(GoodsOrderInfoForm goodsOrderInfoForm) {
         int i = convertOrderInfoForm(goodsOrderInfoForm);
         if (i == 1) {
-            List<GoodsInfoForm> goodsList = goodsOrderInfoForm.getGoodsList();
-            GoodsInfoForm goodsInfoForm = goodsList.get(0);
-            String key = "dec_store_lock_" + goodsInfoForm.getGuid();
-            RLock lock = redissonClient.getLock(key);
-            boolean locked = lock.isLocked();
-            try {
-                //加锁 操作很类似Java的ReentrantLock机制
-                lock.lock();
-                String orderId = orderInfoService.saveFullOrderInfo(goodsOrderInfoForm);
-                if (orderId == null) {
-                    return failure();
-                }
-            } catch (Exception e) {
-                System.out.println(e.getMessage());
+            String orderId = orderInfoService.saveFullOrderInfo(goodsOrderInfoForm);
+            if (orderId == null) {
                 return failure();
-            } finally {
-                //解锁
-                lock.unlock();
             }
             return success(goodsOrderInfoForm);
         } else if (i == -1) {

+ 1 - 3
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/controller/web/WechatAppController.java

@@ -75,7 +75,6 @@ public class WechatAppController extends BaseController {
             if (null == session) {
                 throw new RuntimeException("login handler error");
             }
-
             // 解密用户信息
             WxMaUserInfo wxUserInfo = wxMaService.getUserService().getUserInfo(session.getSessionKey(),
                     request.getEncryptedData(), request.getIv());
@@ -83,7 +82,7 @@ public class WechatAppController extends BaseController {
                 throw new RuntimeException("wxUser not exist");
             }
 
-            MyWxMpUser myWxMpUser=new MyWxMpUser();
+            MyWxMpUser myWxMpUser = new MyWxMpUser();
             //TODO 可以增加自己的逻辑,关联业务相关数据
             myWxMpUser.setOpenId(session.getOpenid());
             myWxMpUser.setUnionId(session.getUnionid());
@@ -127,7 +126,6 @@ public class WechatAppController extends BaseController {
     }
 
 
-
     private MyWxMpUser getMyWxMpUser(WxMaUserInfo userInfo) {
         String openId = userInfo.getOpenId();
         String unionId = userInfo.getUnionId();

+ 31 - 0
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/dao/CustomerCarbonValMapper.java

@@ -0,0 +1,31 @@
+package com.hcloud.microserver.h5.dao;
+
+import com.hcloud.microserver.facade.carbon.entity.CustomerCarbonVal;
+import com.hcloud.microserver.facade.carbon.entity.CustomerCarbonValExample;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface CustomerCarbonValMapper {
+    int countByExample(CustomerCarbonValExample example);
+
+    int deleteByExample(CustomerCarbonValExample example);
+
+    int deleteByPrimaryKey(String guid);
+
+    int insert(CustomerCarbonVal record);
+
+    int insertSelective(CustomerCarbonVal record);
+
+    List<CustomerCarbonVal> selectByExample(CustomerCarbonValExample example);
+
+    CustomerCarbonVal selectByPrimaryKey(String guid);
+
+    int updateByExampleSelective(@Param("record") CustomerCarbonVal record, @Param("example") CustomerCarbonValExample example);
+
+    int updateByExample(@Param("record") CustomerCarbonVal record, @Param("example") CustomerCarbonValExample example);
+
+    int updateByPrimaryKeySelective(CustomerCarbonVal record);
+
+    int updateByPrimaryKey(CustomerCarbonVal record);
+}

+ 1 - 1
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/entity/LoginRequest.java

@@ -11,7 +11,7 @@ public class LoginRequest {
     String signature;
 
     //校验用户信息字符串
-    String rawData;
+    Object rawData;
 
     //加密用户数据
     String encryptedData;

+ 2 - 0
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/service/OrderInfoService.java

@@ -2,6 +2,7 @@ package com.hcloud.microserver.h5.service;
 
 import com.github.pagehelper.PageInfo;
 import com.hcloud.microserver.commoncore.base.BaseServie;
+import com.hcloud.microserver.facade.carbon.entity.from.CreateOrderFrom;
 import com.hcloud.microserver.facade.carbon.forms.GoodsOrderInfoForm;
 
 /**
@@ -74,4 +75,5 @@ public interface OrderInfoService extends BaseServie<GoodsOrderInfoForm,String>
     GoodsOrderInfoForm saveOrderInfoForOffline(GoodsOrderInfoForm goodsOrderInfoForm);
 
 
+    void createOrder(CreateOrderFrom createOrderFrom);
 }

+ 288 - 118
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/service/impl/OrderInfoServiceImpl.java

@@ -2,7 +2,14 @@ package com.hcloud.microserver.h5.service.impl;
 
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.hcloud.microserver.commoncore.base.ResultVO;
+import com.hcloud.microserver.commoncore.enums.ResultEnum;
+import com.hcloud.microserver.facade.carbon.entity.GoodsOrderDetail;
+import com.hcloud.microserver.facade.carbon.entity.from.CreateOrderDetailFrom;
+import com.hcloud.microserver.facade.carbon.entity.from.CreateOrderFrom;
 import com.hcloud.microserver.h5.bo.OrderInfoBO;
+import com.hcloud.microserver.h5.dao.GoodsInfoMapper;
+import com.hcloud.microserver.h5.dao.GoodsOrderDetailMapper;
 import com.hcloud.microserver.h5.dao.GoodsOrderInfoMapper;
 import com.hcloud.microserver.h5.events.CredentialInfoEvent;
 import com.hcloud.microserver.h5.service.*;
@@ -14,13 +21,17 @@ import com.hcloud.microserver.facade.carbon.entity.GoodsInfo;
 import com.hcloud.microserver.facade.carbon.entity.GoodsOrderInfo;
 import com.hcloud.microserver.facade.carbon.forms.*;
 import lombok.extern.slf4j.Slf4j;
+import org.redisson.api.RLock;
+import org.redisson.api.RedissonClient;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.ApplicationContext;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.StringUtils;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.Objects;
@@ -73,8 +84,8 @@ public class OrderInfoServiceImpl implements OrderInfoService {
     @Override
     public PageInfo searchOrderInfoByPage(GoodsOrderInfoForm goodsOrderInfoForm) {
         PageBean pageBean = new PageBean(goodsOrderInfoForm);
-        PageHelper.startPage(goodsOrderInfoForm.getPageNo(),goodsOrderInfoForm.getPageSize());
-        List<OrderInfoBO> list =goodsOrderInfoMapper.searchOrderInfoByPage(pageBean);
+        PageHelper.startPage(goodsOrderInfoForm.getPageNo(), goodsOrderInfoForm.getPageSize());
+        List<OrderInfoBO> list = goodsOrderInfoMapper.searchOrderInfoByPage(pageBean);
         return new PageInfo(list);
     }
 
@@ -86,11 +97,11 @@ public class OrderInfoServiceImpl implements OrderInfoService {
      */
     @Override
     public PageInfo searchOrderInfoByCustomerId(GoodsOrderInfoForm goodsOrderInfoForm) {
-        String customerId= goodsOrderInfoForm.getFkCustomerGuid();
+        String customerId = goodsOrderInfoForm.getFkCustomerGuid();
         Integer orderStatus = goodsOrderInfoForm.getOrderStatus();
-        log.info("page====================>{}",goodsOrderInfoForm.getPage());
-        PageHelper.startPage(goodsOrderInfoForm.getPageNo(),goodsOrderInfoForm.getPageSize());
-        List<OrderInfoBO> list = goodsOrderInfoMapper.searchOrderInfoByCustomerId(customerId,orderStatus);
+        log.info("page====================>{}", goodsOrderInfoForm.getPage());
+        PageHelper.startPage(goodsOrderInfoForm.getPageNo(), goodsOrderInfoForm.getPageSize());
+        List<OrderInfoBO> list = goodsOrderInfoMapper.searchOrderInfoByCustomerId(customerId, orderStatus);
         return new PageInfo(list);
     }
 
@@ -105,16 +116,16 @@ public class OrderInfoServiceImpl implements OrderInfoService {
         GoodsOrderInfoForm goodsOrderInfoForm = new GoodsOrderInfoForm();
         //查询订单信息
         GoodsOrderInfo goodsOrderInfo = goodsOrderInfoMapper.selectByPrimaryKey(orderId);
-        if(null!=goodsOrderInfo && !"".equals(goodsOrderInfo.getOrderNo())){
-            BeanCopyUtil.copyBean(goodsOrderInfo,goodsOrderInfoForm);
+        if (null != goodsOrderInfo && !"".equals(goodsOrderInfo.getOrderNo())) {
+            BeanCopyUtil.copyBean(goodsOrderInfo, goodsOrderInfoForm);
         }
         //查询订单明细信息
         List<GoodsOrderDetailForm> list = orderDetailInfoService.getOrderDetailListByOrderId(orderId);
         goodsOrderInfoForm.setGoodsOrderDetailForm(list);
         //查询支付流水信息
         String payNo = goodsOrderInfoForm.getPayNo();
-        if(null!=payNo && !"".equals(payNo)){
-           GoodsPayOrderForm goodsPayOrderForm = orderPayService.getPayOrderByNo(payNo);
+        if (null != payNo && !"".equals(payNo)) {
+            GoodsPayOrderForm goodsPayOrderForm = orderPayService.getPayOrderByNo(payNo);
             goodsOrderInfoForm.setPayOrderInfo(goodsPayOrderForm);
         }
         //客户信息
@@ -138,13 +149,15 @@ public class OrderInfoServiceImpl implements OrderInfoService {
         goodsOrderInfo.setState(0);
         goodsOrderInfo.setModifiedTime(new Date());
         int i = goodsOrderInfoMapper.updateByPrimaryKeySelective(goodsOrderInfo);
-        if(i>0){
+        if (i > 0) {
             //更新离线支付申请
-           OrderPayApplyForm orderPayApplyForm =  orderPayApplyService.getPayApplyInfoByOrderId(orderId);
-           if(Objects.nonNull(orderPayApplyForm)){
-              int j = orderPayApplyService.modifyByPrimaryKeySelective(orderPayApplyForm);
-              if(j==0){throw new RuntimeException();}
-           }
+            OrderPayApplyForm orderPayApplyForm = orderPayApplyService.getPayApplyInfoByOrderId(orderId);
+            if (Objects.nonNull(orderPayApplyForm)) {
+                int j = orderPayApplyService.modifyByPrimaryKeySelective(orderPayApplyForm);
+                if (j == 0) {
+                    throw new RuntimeException();
+                }
+            }
 
         }
         return i;
@@ -156,58 +169,98 @@ public class OrderInfoServiceImpl implements OrderInfoService {
      * @param goodsOrderInfoForm
      * @return
      */
+
+
+    @Autowired
+    private RedissonClient redissonClient;
+
+
     @Transactional(rollbackFor = Exception.class)
     @Override
     public String saveFullOrderInfo(GoodsOrderInfoForm goodsOrderInfoForm) {
-        //生成订单信息
+        //生成订单信息插入数据库
         int i = this.saveSelective(goodsOrderInfoForm);
-        if(i>0){
-            //生成订单明细
-           List<GoodsOrderDetailForm> list =  goodsOrderInfoForm.getGoodsOrderDetailForm();
-           if(null!=list && list.size()>0){
-               for (GoodsOrderDetailForm bean:list) {
-                   bean.setFkOrderGuid(goodsOrderInfoForm.getGuid());
-                   bean.setState(1);
-                   bean.setModifiedTime(new Date());
-                   bean.setCreateTime(new Date());
-               }
-              int j =  orderDetailInfoService.batchSaveOrderDetailByList(list);
-              if (j==0){throw new RuntimeException();}
-           }else {
-               throw new RuntimeException("order detail list is empty!!!!!");
-            }
-            //更新商品销售表
-            if(null!=list && list.size()>0){
-                for (GoodsOrderDetailForm bean:list) {
-                    BigDecimal saleCarbon = bean.getSaleNum();
-                    String goodsGuid = bean.getFkGoodsGuid();
-                    GoodsSaleInfoForm goodsSaleInfoForm = orderSaleInfoService.getGoodsSaleInfoByGoodsId(goodsGuid);
-                    if(Objects.isNull(goodsSaleInfoForm)){throw new RuntimeException("order sale info is null!!!!!!!");}
-                    BigDecimal saledCarbonSkin = goodsSaleInfoForm.getSaledCarbonSkin().add(saleCarbon);
-                    BigDecimal unSaleCarbonSkin = goodsSaleInfoForm.getUnsaledCarbonSkin().subtract(saleCarbon);
-                    //判断一下商品可售卖的碳汇量是否已经为0,如果为0应该把该商品进行下线操作
-                    if(unSaleCarbonSkin.intValue()==0){
-                        GoodsInfo goodsInfo = new GoodsInfo();
-                        goodsInfo.setGuid(goodsGuid);
-                        goodsInfo.setModifiedTime(new Date());
-                        goodsInfo.setIsSale(0);
-                        int k = goodsInfoService.modifyByPrimaryKeySelective(goodsInfo);
-                        if(k==0){throw new RuntimeException();}
-                    }
-                    goodsSaleInfoForm.setSaledCarbonSkin(saledCarbonSkin);
-                    goodsSaleInfoForm.setUnsaledCarbonSkin(unSaleCarbonSkin);
-                    goodsSaleInfoForm.setModifiedTime(new Date());
-                    int h =orderSaleInfoService.modifyByPrimaryKeySelective(goodsSaleInfoForm);
-                    if(h==0){
-                        throw new RuntimeException();
-                    }
-                }
-            }
+        if (i > 0) {
+            //批量生成订单明细插入数据库
+            List<GoodsOrderDetailForm> list = goodsOrderInfoForm.getGoodsOrderDetailForm();
+            boolean b = null != list && list.size() > 0;
+            //批量生成订单明细插入数据库
+            insertListData(goodsOrderInfoForm, list, b);
+            //批量更新商品销售表
+            updateListData(list, b);
             return goodsOrderInfoForm.getGuid();
         }
         return null;
     }
 
+    private void updateListData(List<GoodsOrderDetailForm> list, boolean b) {
+        if (b) {
+            for (GoodsOrderDetailForm bean : list) {
+                BigDecimal saleCarbon = bean.getSaleNum();
+                String goodsGuid = bean.getFkGoodsGuid();
+                String key = "dec_store_lock_" + goodsGuid;
+                RLock lock = redissonClient.getLock(key);
+                boolean locked = lock.isLocked();
+                try {
+                    //加锁 操作很类似Java的ReentrantLock机制
+                    lock.lock();
+                    updateGoods(saleCarbon, goodsGuid);
+                } catch (Exception e) {
+                    System.out.println(e.getMessage());
+                    throw new RuntimeException("请重新抢购");
+                } finally {
+                    //解锁
+                    lock.unlock();
+                }
+
+            }
+        }
+    }
+
+    private void insertListData(GoodsOrderInfoForm goodsOrderInfoForm, List<GoodsOrderDetailForm> list, boolean b) {
+        if (b) {
+            for (GoodsOrderDetailForm bean : list) {
+                bean.setFkOrderGuid(goodsOrderInfoForm.getGuid());
+                bean.setState(1);
+                bean.setModifiedTime(new Date());
+                bean.setCreateTime(new Date());
+            }
+            int j = orderDetailInfoService.batchSaveOrderDetailByList(list);
+            if (j == 0) {
+                throw new RuntimeException();
+            }
+        } else {
+            throw new RuntimeException("order detail list is empty!!!!!");
+        }
+    }
+
+    private void updateGoods(BigDecimal saleCarbon, String goodsGuid) {
+        GoodsSaleInfoForm goodsSaleInfoForm = orderSaleInfoService.getGoodsSaleInfoByGoodsId(goodsGuid);
+        if (Objects.isNull(goodsSaleInfoForm)) {
+            throw new RuntimeException("order sale info is null!!!!!!!");
+        }
+        BigDecimal saledCarbonSkin = goodsSaleInfoForm.getSaledCarbonSkin().add(saleCarbon);
+        BigDecimal unSaleCarbonSkin = goodsSaleInfoForm.getUnsaledCarbonSkin().subtract(saleCarbon);
+        //判断一下商品可售卖的碳汇量是否已经为0,如果为0应该把该商品进行下线操作
+        if (unSaleCarbonSkin.intValue() == 0) {
+            GoodsInfo goodsInfo = new GoodsInfo();
+            goodsInfo.setGuid(goodsGuid);
+            goodsInfo.setModifiedTime(new Date());
+            goodsInfo.setIsSale(0);
+            int k = goodsInfoService.modifyByPrimaryKeySelective(goodsInfo);
+            if (k == 0) {
+                throw new RuntimeException();
+            }
+        }
+        goodsSaleInfoForm.setSaledCarbonSkin(saledCarbonSkin);
+        goodsSaleInfoForm.setUnsaledCarbonSkin(unSaleCarbonSkin);
+        goodsSaleInfoForm.setModifiedTime(new Date());
+        int h = orderSaleInfoService.modifyByPrimaryKeySelective(goodsSaleInfoForm);
+        if (h == 0) {
+            throw new RuntimeException();
+        }
+    }
+
     /**
      * 支付成功后回调更新(订单信息,支付流水信息,证书信息,农户销售统计信息(集体户统计到集体户上))
      *
@@ -216,49 +269,54 @@ public class OrderInfoServiceImpl implements OrderInfoService {
      */
     @Transactional(rollbackFor = Exception.class)
     @Override
-    public int updateFullOrderInfo(String payNo,Integer state) {
-        if(null!=payNo && !"".equals(payNo)){
+    public int updateFullOrderInfo(String payNo, Integer state) {
+        if (null != payNo && !"".equals(payNo)) {
             //查询支付订单
-           GoodsPayOrderForm goodsPayOrderForm = orderPayService.getPayOrderByNo(payNo);
-           if(goodsPayOrderForm!=null && !"".equals(goodsPayOrderForm.getFkOrderId())){
-               //更新订单信息
-               String orderId = goodsPayOrderForm.getFkOrderId();
-               GoodsOrderInfo goodsOrderInfo = goodsOrderInfoMapper.selectByPrimaryKey(orderId);
-               goodsOrderInfo.setOrderStatus(state);
-               goodsOrderInfo.setModifiedTime(new Date());
-               int i = goodsOrderInfoMapper.updateByPrimaryKeySelective(goodsOrderInfo);
-               if(i>0){
-                   //更新支付订单信息
-                   goodsPayOrderForm.setPayStatus(state);
-                   goodsPayOrderForm.setPayTime(new Date());
-                   int j = orderPayService.modifyByPrimaryKeySelective(goodsPayOrderForm);
-                   if(j==0){throw new RuntimeException();}
-                   //更新农户收入信息
-                   updateFarmerSaleInfo(orderId);
-                   //生成证书信息
-                   applicationContext.publishEvent(new CredentialInfoEvent(new Object(),orderId));
-                   return i;
-               }else{
-                   throw new RuntimeException();
-               }
-           }
+            GoodsPayOrderForm goodsPayOrderForm = orderPayService.getPayOrderByNo(payNo);
+            if (goodsPayOrderForm != null && !"".equals(goodsPayOrderForm.getFkOrderId())) {
+                //更新订单信息
+                String orderId = goodsPayOrderForm.getFkOrderId();
+                GoodsOrderInfo goodsOrderInfo = goodsOrderInfoMapper.selectByPrimaryKey(orderId);
+                goodsOrderInfo.setOrderStatus(state);
+                goodsOrderInfo.setModifiedTime(new Date());
+                int i = goodsOrderInfoMapper.updateByPrimaryKeySelective(goodsOrderInfo);
+                if (i > 0) {
+                    //更新支付订单信息
+                    goodsPayOrderForm.setPayStatus(state);
+                    goodsPayOrderForm.setPayTime(new Date());
+                    int j = orderPayService.modifyByPrimaryKeySelective(goodsPayOrderForm);
+                    if (j == 0) {
+                        throw new RuntimeException();
+                    }
+                    //更新农户收入信息
+                    updateFarmerSaleInfo(orderId);
+                    //生成证书信息
+                    applicationContext.publishEvent(new CredentialInfoEvent(new Object(), orderId));
+                    return i;
+                } else {
+                    throw new RuntimeException();
+                }
+            }
         }
         return 0;
     }
 
     /**
      * 统计订单详情里商品关联的农户信息,在支付成功后更新农户销售信息
+     *
      * @param orderId
      * @throws RuntimeException
      */
-    private void updateFarmerSaleInfo(String orderId) throws RuntimeException{
+    private void updateFarmerSaleInfo(String orderId) throws RuntimeException {
         List<GoodsOrderDetailForm> detailList = orderDetailInfoService.getOrderDetailListByOrderId(orderId);
-        if(null!=detailList && detailList.size()>0){
-            for (GoodsOrderDetailForm bean:detailList) {
+        if (null != detailList && detailList.size() > 0) {
+            for (GoodsOrderDetailForm bean : detailList) {
                 String goodsGuid = bean.getFkGoodsGuid();
                 BigDecimal carbonAmount = bean.getAmount();
-                int i =farmerInfoService.updateFarmerSaleInfoByGoodsId(carbonAmount,goodsGuid);
-                if(i==0){throw new RuntimeException();}
+                int i = farmerInfoService.updateFarmerSaleInfoByGoodsId(carbonAmount, goodsGuid);
+                if (i == 0) {
+                    throw new RuntimeException();
+                }
             }
         }
     }
@@ -266,22 +324,25 @@ public class OrderInfoServiceImpl implements OrderInfoService {
 
     /**
      * 支付失败或超过订单支付时间时,进行订单回滚操作
+     *
      * @param orderId
      * @return
      */
     @Transactional(rollbackFor = Exception.class)
     @Override
-    public int rollbackOrderInfo(String orderId){
+    public int rollbackOrderInfo(String orderId) {
         GoodsOrderInfo goodsOrderInfo = goodsOrderInfoMapper.selectByPrimaryKey(orderId);
         goodsOrderInfo.setOrderStatus(4);
         goodsOrderInfo.setState(0);
         goodsOrderInfo.setModifiedTime(new Date());
         int i = goodsOrderInfoMapper.updateByPrimaryKeySelective(goodsOrderInfo);
-        if(i==0){throw new RuntimeException();}
+        if (i == 0) {
+            throw new RuntimeException();
+        }
         String guid = goodsOrderInfo.getGuid();
         List<GoodsOrderDetailForm> orderDetailList = orderDetailInfoService.getOrderDetailListByOrderId(guid);
-        if(null!=orderDetailList && orderDetailList.size()>0){
-            for(GoodsOrderDetailForm bean:orderDetailList) {
+        if (null != orderDetailList && orderDetailList.size() > 0) {
+            for (GoodsOrderDetailForm bean : orderDetailList) {
                 BigDecimal saleCarbon = bean.getSaleNum();
                 String goodsGuid = bean.getFkGoodsGuid();
                 GoodsSaleInfoForm goodsSaleInfoForm = orderSaleInfoService.getGoodsSaleInfoByGoodsId(goodsGuid);
@@ -290,20 +351,22 @@ public class OrderInfoServiceImpl implements OrderInfoService {
                 goodsSaleInfoForm.setSaledCarbonSkin(saledCarbonSkin);
                 goodsSaleInfoForm.setUnsaledCarbonSkin(unSaleCarbonSkin);
                 goodsSaleInfoForm.setModifiedTime(new Date());
-                int h =orderSaleInfoService.modifiedOrderSaleInfo(goodsSaleInfoForm);
-                if(h==0){
+                int h = orderSaleInfoService.modifiedOrderSaleInfo(goodsSaleInfoForm);
+                if (h == 0) {
                     throw new RuntimeException();
                 }
             }
         }
         //取消离线支付订单
         OrderPayApplyForm payApplyForm = orderPayApplyService.getPayApplyInfoByOrderId(orderId);
-        if(Objects.nonNull(payApplyForm)){
+        if (Objects.nonNull(payApplyForm)) {
             payApplyForm.setState(0);
             payApplyForm.setApplyStatus(4);
             payApplyForm.setModifiedTime(new Date());
-           int h = orderPayApplyService.modifyByPrimaryKeySelective(payApplyForm);
-           if(h==0){throw new RuntimeException();}
+            int h = orderPayApplyService.modifyByPrimaryKeySelective(payApplyForm);
+            if (h == 0) {
+                throw new RuntimeException();
+            }
         }
         return i;
     }
@@ -316,10 +379,10 @@ public class OrderInfoServiceImpl implements OrderInfoService {
      */
     @Override
     public GoodsOrderInfoForm getOrderInfoByNo(String orderNo) {
-       GoodsOrderInfo orderInfo = goodsOrderInfoMapper.getOrderInfoByNo(orderNo);
-       if(Objects.nonNull(orderInfo)){
-           return BeanCopyUtil.convertBean(orderInfo,GoodsOrderInfoForm.class);
-       }
+        GoodsOrderInfo orderInfo = goodsOrderInfoMapper.getOrderInfoByNo(orderNo);
+        if (Objects.nonNull(orderInfo)) {
+            return BeanCopyUtil.convertBean(orderInfo, GoodsOrderInfoForm.class);
+        }
         return null;
     }
 
@@ -332,24 +395,26 @@ public class OrderInfoServiceImpl implements OrderInfoService {
     @Override
     public GoodsOrderInfoForm saveOrderInfoForOffline(GoodsOrderInfoForm goodsOrderInfoForm) {
         int i = this.saveSelective(goodsOrderInfoForm);
-        if(i>0){
+        if (i > 0) {
             //生成订单明细
-            List<GoodsOrderDetailForm> detaillist =  goodsOrderInfoForm.getGoodsOrderDetailForm();
-            if(null!=detaillist && detaillist.size()>0){
-                for (GoodsOrderDetailForm bean:detaillist) {
+            List<GoodsOrderDetailForm> detaillist = goodsOrderInfoForm.getGoodsOrderDetailForm();
+            if (null != detaillist && detaillist.size() > 0) {
+                for (GoodsOrderDetailForm bean : detaillist) {
                     bean.setFkOrderGuid(goodsOrderInfoForm.getGuid());
                     bean.setState(1);
                     bean.setModifiedTime(new Date());
                     bean.setCreateTime(new Date());
                 }
-                int j =  orderDetailInfoService.batchSaveOrderDetailByList(detaillist);
-                if (j==0){throw new RuntimeException();}
-            }else {
+                int j = orderDetailInfoService.batchSaveOrderDetailByList(detaillist);
+                if (j == 0) {
+                    throw new RuntimeException();
+                }
+            } else {
                 throw new RuntimeException("order detail list is empty!!!!!");
             }
             //更新商品销售表
-            if(null!=detaillist && detaillist.size()>0){
-                for (GoodsOrderDetailForm bean:detaillist) {
+            if (null != detaillist && detaillist.size() > 0) {
+                for (GoodsOrderDetailForm bean : detaillist) {
                     BigDecimal saleCarbon = bean.getSaleNum();
                     String goodsGuid = bean.getFkGoodsGuid();
                     GoodsSaleInfoForm goodsSaleInfoForm = orderSaleInfoService.queryByPrimaryKey(goodsGuid);
@@ -358,8 +423,8 @@ public class OrderInfoServiceImpl implements OrderInfoService {
                     goodsSaleInfoForm.setSaledCarbonSkin(saledCarbonSkin);
                     goodsSaleInfoForm.setUnsaledCarbonSkin(unSaleCarbonSkin);
                     goodsSaleInfoForm.setModifiedTime(new Date());
-                    int h =orderSaleInfoService.modifiedOrderSaleInfo(goodsSaleInfoForm);
-                    if(h==0){
+                    int h = orderSaleInfoService.modifiedOrderSaleInfo(goodsSaleInfoForm);
+                    if (h == 0) {
                         throw new RuntimeException();
                     }
                 }
@@ -377,7 +442,7 @@ public class OrderInfoServiceImpl implements OrderInfoService {
 
     @Override
     public int save(GoodsOrderInfoForm record) {
-        GoodsOrderInfo goodsOrderInfo = BeanCopyUtil.convertBean(record,GoodsOrderInfo.class);
+        GoodsOrderInfo goodsOrderInfo = BeanCopyUtil.convertBean(record, GoodsOrderInfo.class);
         GeneratorIdUtils generatorIdUtils = new GeneratorIdUtils();
         String orderNum = generatorIdUtils.nextId();
         goodsOrderInfo.setGuid(GetUUID.getUUID());
@@ -398,19 +463,19 @@ public class OrderInfoServiceImpl implements OrderInfoService {
         record.setState(1);
         record.setCreateTime(new Date());
         record.setModifiedTime(new Date());
-        GoodsOrderInfo goodsOrderInfo = BeanCopyUtil.convertBean(record,GoodsOrderInfo.class);
+        GoodsOrderInfo goodsOrderInfo = BeanCopyUtil.convertBean(record, GoodsOrderInfo.class);
         return goodsOrderInfoMapper.insertSelective(goodsOrderInfo);
     }
 
     @Override
     public GoodsOrderInfoForm queryByPrimaryKey(String guid) {
         GoodsOrderInfo goodsOrderInfo = goodsOrderInfoMapper.selectByPrimaryKey(guid);
-        return BeanCopyUtil.convertBean(goodsOrderInfo,GoodsOrderInfoForm.class);
+        return BeanCopyUtil.convertBean(goodsOrderInfo, GoodsOrderInfoForm.class);
     }
 
     @Override
     public int modifyByPrimaryKeySelective(GoodsOrderInfoForm record) {
-        GoodsOrderInfo goodsOrderInfo = BeanCopyUtil.convertBean(record,GoodsOrderInfo.class);
+        GoodsOrderInfo goodsOrderInfo = BeanCopyUtil.convertBean(record, GoodsOrderInfo.class);
         return goodsOrderInfoMapper.updateByPrimaryKeySelective(goodsOrderInfo);
     }
 
@@ -422,7 +487,112 @@ public class OrderInfoServiceImpl implements OrderInfoService {
 
     @Override
     public int modifyByPrimaryKey(GoodsOrderInfoForm record) {
-        GoodsOrderInfo goodsOrderInfo = BeanCopyUtil.convertBean(record,GoodsOrderInfo.class);
+        GoodsOrderInfo goodsOrderInfo = BeanCopyUtil.convertBean(record, GoodsOrderInfo.class);
         return goodsOrderInfoMapper.updateByPrimaryKey(goodsOrderInfo);
     }
+
+    @Autowired
+    private CustomerService customerService;
+
+    @Autowired
+    private GoodsInfoMapper goodsInfoMapper;
+
+    @Autowired
+    private GoodsOrderDetailMapper goodsOrderDetailMapper;
+
+    @Override
+    @Transactional
+    public void createOrder(CreateOrderFrom createOrderFrom) {
+        //获取登陆人信息
+        CustomerInfoForm customerInfo = customerService.getCurrentMember();
+        if (customerInfo == null) {
+            throw new RuntimeException("获取登陆信息失败");
+        }
+        String customerId = customerInfo.getGuid();
+
+        List<CreateOrderDetailFrom> goods = createOrderFrom.getGoods();
+        //全部订单总价
+        BigDecimal sumTotal = new BigDecimal(0);
+        //全部碳汇量
+        BigDecimal carbonTotal = new BigDecimal(0);
+        String orderId = GetUUID.getUUID();
+        List<GoodsOrderDetail> dataList = new ArrayList<>();
+        for (CreateOrderDetailFrom good : goods) {
+            String goodsId = good.getGoodsId();
+            //购买的碳汇量
+            BigDecimal carbonVal = good.getCarbonVal();
+            GoodsInfo goodsInfo = goodsInfoMapper.selectByPrimaryKey(goodsId);
+            String guid = goodsInfo.getGuid();
+            //还剩碳汇量
+            BigDecimal carbonValRe = goodsInfo.getCarbonVal();
+            if (StringUtils.isEmpty(carbonValRe)) {
+                throw new RuntimeException("碳汇量不够了");
+            }
+            if (carbonVal.compareTo(carbonValRe) == 1) {
+                throw new RuntimeException("购买的碳汇量大于剩余的碳汇量");
+            }
+            //商品单价
+            BigDecimal price = goodsInfo.getPrice();
+            //单个碳汇总价
+            BigDecimal sum = carbonVal.multiply(price);
+
+            sumTotal = sumTotal.add(sum);
+
+            carbonTotal = carbonTotal.add(carbonVal);
+            //剩余碳汇量
+            BigDecimal reCarbonVal = carbonValRe.subtract(carbonVal);
+            goodsInfo.setCarbonVal(reCarbonVal);
+            goodsInfoMapper.updateByPrimaryKeySelective(goodsInfo);
+
+            //获取小订单
+            addGoodsOrderDetail(customerId, orderId, dataList, good, goodsInfo, sum);
+        }
+        GoodsOrderInfo goodsOrderInfo = new GoodsOrderInfo();
+        //构建大订单参数
+        addGoodsOrderInfo(customerInfo, customerId, sumTotal, carbonTotal, orderId, goodsOrderInfo);
+        //新增大定单
+        goodsOrderInfoMapper.insertSelective(goodsOrderInfo);
+        //新增小定单
+        goodsOrderDetailMapper.batchSaveOrderDetailList(dataList);
+
+    }
+
+    private void addGoodsOrderInfo(CustomerInfoForm customerInfo, String customerId, BigDecimal sumTotal, BigDecimal carbonTotal, String orderId, GoodsOrderInfo goodsOrderInfo) {
+        GeneratorIdUtils generatorIdUtils = new GeneratorIdUtils();
+        String orderNum = generatorIdUtils.nextId();
+        //构建订单信息
+        goodsOrderInfo.setFkCustomerGuid(customerId);
+        goodsOrderInfo.setCustomerName(customerInfo.getCustomerName());
+        goodsOrderInfo.setCustomerType(customerInfo.getCustomerType().toString());
+        //返回生成的订单id和订单编号
+        goodsOrderInfo.setGuid(orderId);
+        goodsOrderInfo.setOrderNo(orderNum);
+        goodsOrderInfo.setCreateUser(customerId);
+        goodsOrderInfo.setCreateTime(new Date());
+        goodsOrderInfo.setOrderStatus(1);
+        //碳汇总价
+        goodsOrderInfo.setOrderAmount(sumTotal);
+        //碳汇总数量
+        goodsOrderInfo.setOrderCarbonAmount(carbonTotal);
+    }
+
+    private void addGoodsOrderDetail(String customerId, String orderId, List<GoodsOrderDetail> dataList, CreateOrderDetailFrom good, GoodsInfo goodsInfo, BigDecimal sum) {
+        GoodsOrderDetail goodsOrderDetail = new GoodsOrderDetail();
+        goodsOrderDetail.setGuid(GetUUID.getUUID());
+        goodsOrderDetail.setCreateUser(customerId);
+        goodsOrderDetail.setCreateTime(new Date());
+        goodsOrderDetail.setGoodsPrice(goodsInfo.getPrice());
+        //设置单个销售总价
+        goodsOrderDetail.setAmount(sum);
+        //设置谈汇量
+        goodsOrderDetail.setSaleNum(good.getCarbonVal());
+        //设置商品id
+        goodsOrderDetail.setFkGoodsGuid(goodsInfo.getGuid());
+        //设置商品名称
+        goodsOrderDetail.setGoodsName(goodsInfo.getGoodsName());
+        goodsOrderDetail.setFkOrderGuid(orderId);
+        goodsOrderDetail.setState(1);
+
+        dataList.add(goodsOrderDetail);
+    }
 }

+ 353 - 0
carbon-h5/carbon-h5-service/src/main/resources/com/hcloud/microserver/h5/dao/CustomerCarbonValMapper.xml

@@ -0,0 +1,353 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.hcloud.microserver.h5.dao.CustomerCarbonValMapper" >
+  <resultMap id="BaseResultMap" type="com.hcloud.microserver.facade.carbon.entity.CustomerCarbonVal" >
+    <id column="guid" property="guid" jdbcType="CHAR" />
+    <result column="t_customer_id" property="tCustomerId" jdbcType="CHAR" />
+    <result column="t_customer_name" property="tCustomerName" jdbcType="VARCHAR" />
+    <result column="carbon_val" property="carbonVal" jdbcType="DECIMAL" />
+    <result column="status" property="status" jdbcType="INTEGER" />
+    <result column="type" property="type" jdbcType="INTEGER" />
+    <result column="tb_guid" property="tbGuid" jdbcType="CHAR" />
+    <result column="tb_name" property="tbName" jdbcType="CHAR" />
+    <result column="remarks" property="remarks" jdbcType="CHAR" />
+    <result column="year_time" property="yearTime" jdbcType="INTEGER" />
+    <result column="create_user" property="createUser" jdbcType="CHAR" />
+    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
+    <result column="update_user" property="updateUser" jdbcType="CHAR" />
+    <result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
+  </resultMap>
+  <sql id="Example_Where_Clause" >
+    <where >
+      <foreach collection="oredCriteria" item="criteria" separator="or" >
+        <if test="criteria.valid" >
+          <trim prefix="(" suffix=")" prefixOverrides="and" >
+            <foreach collection="criteria.criteria" item="criterion" >
+              <choose >
+                <when test="criterion.noValue" >
+                  and ${criterion.condition}
+                </when>
+                <when test="criterion.singleValue" >
+                  and ${criterion.condition} #{criterion.value}
+                </when>
+                <when test="criterion.betweenValue" >
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                </when>
+                <when test="criterion.listValue" >
+                  and ${criterion.condition}
+                  <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
+                    #{listItem}
+                  </foreach>
+                </when>
+              </choose>
+            </foreach>
+          </trim>
+        </if>
+      </foreach>
+    </where>
+  </sql>
+  <sql id="Update_By_Example_Where_Clause" >
+    <where >
+      <foreach collection="example.oredCriteria" item="criteria" separator="or" >
+        <if test="criteria.valid" >
+          <trim prefix="(" suffix=")" prefixOverrides="and" >
+            <foreach collection="criteria.criteria" item="criterion" >
+              <choose >
+                <when test="criterion.noValue" >
+                  and ${criterion.condition}
+                </when>
+                <when test="criterion.singleValue" >
+                  and ${criterion.condition} #{criterion.value}
+                </when>
+                <when test="criterion.betweenValue" >
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                </when>
+                <when test="criterion.listValue" >
+                  and ${criterion.condition}
+                  <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
+                    #{listItem}
+                  </foreach>
+                </when>
+              </choose>
+            </foreach>
+          </trim>
+        </if>
+      </foreach>
+    </where>
+  </sql>
+  <sql id="Base_Column_List" >
+    guid, t_customer_id, t_customer_name, carbon_val, status, type, tb_guid, tb_name, 
+    remarks, year_time, create_user, create_time, update_user, update_time
+  </sql>
+  <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.hcloud.microserver.facade.carbon.entity.CustomerCarbonValExample" >
+    select
+    <if test="distinct" >
+      distinct
+    </if>
+    <include refid="Base_Column_List" />
+    from t_customer_carbon_val
+    <if test="_parameter != null" >
+      <include refid="Example_Where_Clause" />
+    </if>
+    <if test="orderByClause != null" >
+      order by ${orderByClause}
+    </if>
+  </select>
+  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
+    select 
+    <include refid="Base_Column_List" />
+    from t_customer_carbon_val
+    where guid = #{guid,jdbcType=CHAR}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
+    delete from t_customer_carbon_val
+    where guid = #{guid,jdbcType=CHAR}
+  </delete>
+  <delete id="deleteByExample" parameterType="com.hcloud.microserver.facade.carbon.entity.CustomerCarbonValExample" >
+    delete from t_customer_carbon_val
+    <if test="_parameter != null" >
+      <include refid="Example_Where_Clause" />
+    </if>
+  </delete>
+  <insert id="insert" parameterType="com.hcloud.microserver.facade.carbon.entity.CustomerCarbonVal" >
+    insert into t_customer_carbon_val (guid, t_customer_id, t_customer_name, 
+      carbon_val, status, type, 
+      tb_guid, tb_name, remarks, year_time, 
+      create_user, create_time, update_user, 
+      update_time)
+    values (#{guid,jdbcType=CHAR}, #{tCustomerId,jdbcType=CHAR}, #{tCustomerName,jdbcType=VARCHAR}, 
+      #{carbonVal,jdbcType=DECIMAL}, #{status,jdbcType=INTEGER}, #{type,jdbcType=INTEGER}, 
+      #{tbGuid,jdbcType=CHAR}, #{tbName,jdbcType=CHAR}, #{remarks,jdbcType=CHAR}, #{yearTime,jdbcType=INTEGER}, 
+      #{createUser,jdbcType=CHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateUser,jdbcType=CHAR}, 
+      #{updateTime,jdbcType=TIMESTAMP})
+  </insert>
+  <insert id="insertSelective" parameterType="com.hcloud.microserver.facade.carbon.entity.CustomerCarbonVal" >
+    insert into t_customer_carbon_val
+    <trim prefix="(" suffix=")" suffixOverrides="," >
+      <if test="guid != null" >
+        guid,
+      </if>
+      <if test="tCustomerId != null" >
+        t_customer_id,
+      </if>
+      <if test="tCustomerName != null" >
+        t_customer_name,
+      </if>
+      <if test="carbonVal != null" >
+        carbon_val,
+      </if>
+      <if test="status != null" >
+        status,
+      </if>
+      <if test="type != null" >
+        type,
+      </if>
+      <if test="tbGuid != null" >
+        tb_guid,
+      </if>
+      <if test="tbName != null" >
+        tb_name,
+      </if>
+      <if test="remarks != null" >
+        remarks,
+      </if>
+      <if test="yearTime != null" >
+        year_time,
+      </if>
+      <if test="createUser != null" >
+        create_user,
+      </if>
+      <if test="createTime != null" >
+        create_time,
+      </if>
+      <if test="updateUser != null" >
+        update_user,
+      </if>
+      <if test="updateTime != null" >
+        update_time,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides="," >
+      <if test="guid != null" >
+        #{guid,jdbcType=CHAR},
+      </if>
+      <if test="tCustomerId != null" >
+        #{tCustomerId,jdbcType=CHAR},
+      </if>
+      <if test="tCustomerName != null" >
+        #{tCustomerName,jdbcType=VARCHAR},
+      </if>
+      <if test="carbonVal != null" >
+        #{carbonVal,jdbcType=DECIMAL},
+      </if>
+      <if test="status != null" >
+        #{status,jdbcType=INTEGER},
+      </if>
+      <if test="type != null" >
+        #{type,jdbcType=INTEGER},
+      </if>
+      <if test="tbGuid != null" >
+        #{tbGuid,jdbcType=CHAR},
+      </if>
+      <if test="tbName != null" >
+        #{tbName,jdbcType=CHAR},
+      </if>
+      <if test="remarks != null" >
+        #{remarks,jdbcType=CHAR},
+      </if>
+      <if test="yearTime != null" >
+        #{yearTime,jdbcType=INTEGER},
+      </if>
+      <if test="createUser != null" >
+        #{createUser,jdbcType=CHAR},
+      </if>
+      <if test="createTime != null" >
+        #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="updateUser != null" >
+        #{updateUser,jdbcType=CHAR},
+      </if>
+      <if test="updateTime != null" >
+        #{updateTime,jdbcType=TIMESTAMP},
+      </if>
+    </trim>
+  </insert>
+  <select id="countByExample" parameterType="com.hcloud.microserver.facade.carbon.entity.CustomerCarbonValExample" resultType="java.lang.Integer" >
+    select count(*) from t_customer_carbon_val
+    <if test="_parameter != null" >
+      <include refid="Example_Where_Clause" />
+    </if>
+  </select>
+  <update id="updateByExampleSelective" parameterType="map" >
+    update t_customer_carbon_val
+    <set >
+      <if test="record.guid != null" >
+        guid = #{record.guid,jdbcType=CHAR},
+      </if>
+      <if test="record.tCustomerId != null" >
+        t_customer_id = #{record.tCustomerId,jdbcType=CHAR},
+      </if>
+      <if test="record.tCustomerName != null" >
+        t_customer_name = #{record.tCustomerName,jdbcType=VARCHAR},
+      </if>
+      <if test="record.carbonVal != null" >
+        carbon_val = #{record.carbonVal,jdbcType=DECIMAL},
+      </if>
+      <if test="record.status != null" >
+        status = #{record.status,jdbcType=INTEGER},
+      </if>
+      <if test="record.type != null" >
+        type = #{record.type,jdbcType=INTEGER},
+      </if>
+      <if test="record.tbGuid != null" >
+        tb_guid = #{record.tbGuid,jdbcType=CHAR},
+      </if>
+      <if test="record.tbName != null" >
+        tb_name = #{record.tbName,jdbcType=CHAR},
+      </if>
+      <if test="record.remarks != null" >
+        remarks = #{record.remarks,jdbcType=CHAR},
+      </if>
+      <if test="record.yearTime != null" >
+        year_time = #{record.yearTime,jdbcType=INTEGER},
+      </if>
+      <if test="record.createUser != null" >
+        create_user = #{record.createUser,jdbcType=CHAR},
+      </if>
+      <if test="record.createTime != null" >
+        create_time = #{record.createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="record.updateUser != null" >
+        update_user = #{record.updateUser,jdbcType=CHAR},
+      </if>
+      <if test="record.updateTime != null" >
+        update_time = #{record.updateTime,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    <if test="_parameter != null" >
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByExample" parameterType="map" >
+    update t_customer_carbon_val
+    set guid = #{record.guid,jdbcType=CHAR},
+      t_customer_id = #{record.tCustomerId,jdbcType=CHAR},
+      t_customer_name = #{record.tCustomerName,jdbcType=VARCHAR},
+      carbon_val = #{record.carbonVal,jdbcType=DECIMAL},
+      status = #{record.status,jdbcType=INTEGER},
+      type = #{record.type,jdbcType=INTEGER},
+      tb_guid = #{record.tbGuid,jdbcType=CHAR},
+      tb_name = #{record.tbName,jdbcType=CHAR},
+      remarks = #{record.remarks,jdbcType=CHAR},
+      year_time = #{record.yearTime,jdbcType=INTEGER},
+      create_user = #{record.createUser,jdbcType=CHAR},
+      create_time = #{record.createTime,jdbcType=TIMESTAMP},
+      update_user = #{record.updateUser,jdbcType=CHAR},
+      update_time = #{record.updateTime,jdbcType=TIMESTAMP}
+    <if test="_parameter != null" >
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByPrimaryKeySelective" parameterType="com.hcloud.microserver.facade.carbon.entity.CustomerCarbonVal" >
+    update t_customer_carbon_val
+    <set >
+      <if test="tCustomerId != null" >
+        t_customer_id = #{tCustomerId,jdbcType=CHAR},
+      </if>
+      <if test="tCustomerName != null" >
+        t_customer_name = #{tCustomerName,jdbcType=VARCHAR},
+      </if>
+      <if test="carbonVal != null" >
+        carbon_val = #{carbonVal,jdbcType=DECIMAL},
+      </if>
+      <if test="status != null" >
+        status = #{status,jdbcType=INTEGER},
+      </if>
+      <if test="type != null" >
+        type = #{type,jdbcType=INTEGER},
+      </if>
+      <if test="tbGuid != null" >
+        tb_guid = #{tbGuid,jdbcType=CHAR},
+      </if>
+      <if test="tbName != null" >
+        tb_name = #{tbName,jdbcType=CHAR},
+      </if>
+      <if test="remarks != null" >
+        remarks = #{remarks,jdbcType=CHAR},
+      </if>
+      <if test="yearTime != null" >
+        year_time = #{yearTime,jdbcType=INTEGER},
+      </if>
+      <if test="createUser != null" >
+        create_user = #{createUser,jdbcType=CHAR},
+      </if>
+      <if test="createTime != null" >
+        create_time = #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="updateUser != null" >
+        update_user = #{updateUser,jdbcType=CHAR},
+      </if>
+      <if test="updateTime != null" >
+        update_time = #{updateTime,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    where guid = #{guid,jdbcType=CHAR}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.hcloud.microserver.facade.carbon.entity.CustomerCarbonVal" >
+    update t_customer_carbon_val
+    set t_customer_id = #{tCustomerId,jdbcType=CHAR},
+      t_customer_name = #{tCustomerName,jdbcType=VARCHAR},
+      carbon_val = #{carbonVal,jdbcType=DECIMAL},
+      status = #{status,jdbcType=INTEGER},
+      type = #{type,jdbcType=INTEGER},
+      tb_guid = #{tbGuid,jdbcType=CHAR},
+      tb_name = #{tbName,jdbcType=CHAR},
+      remarks = #{remarks,jdbcType=CHAR},
+      year_time = #{yearTime,jdbcType=INTEGER},
+      create_user = #{createUser,jdbcType=CHAR},
+      create_time = #{createTime,jdbcType=TIMESTAMP},
+      update_user = #{updateUser,jdbcType=CHAR},
+      update_time = #{updateTime,jdbcType=TIMESTAMP}
+    where guid = #{guid,jdbcType=CHAR}
+  </update>
+</mapper>

+ 26 - 6
carbon-h5/carbon-h5-service/src/main/resources/com/hcloud/microserver/h5/dao/GoodsOrderDetailMapper.xml

@@ -63,13 +63,33 @@
       #{createTime,jdbcType=TIMESTAMP})
   </insert>
   <insert id="batchSaveOrderDetailList">
-        insert into t_goods_order_detail (guid, fk_order_guid, fk_goods_guid,
-      goods_name, goods_price, sale_num,
-      amount, state,create_time) values
+        insert into t_goods_order_detail
+        (
+        guid,
+        fk_order_guid,
+        fk_goods_guid,
+        goods_name,
+        goods_price,
+        sale_num,
+        amount,
+        state,
+        create_user,
+        create_time
+        )
+      values
       <foreach collection="list" item="bean" separator="," open="" close="">
-       ( REPLACE(UUID(),'-',''), #{bean.fkOrderGuid,jdbcType=CHAR}, #{bean.fkGoodsGuid,jdbcType=CHAR},
-        #{bean.goodsName,jdbcType=VARCHAR}, #{bean.goodsPrice,jdbcType=DECIMAL}, #{bean.saleNum,jdbcType=DECIMAL},
-        #{bean.amount,jdbcType=DECIMAL}, #{bean.state,jdbcType=INTEGER},#{bean.createTime,jdbcType=TIMESTAMP})
+       (
+          REPLACE(UUID(),'-',''),
+          #{bean.fkOrderGuid,jdbcType=CHAR},
+          #{bean.fkGoodsGuid,jdbcType=CHAR},
+          #{bean.goodsName,jdbcType=VARCHAR},
+          #{bean.goodsPrice,jdbcType=DECIMAL},
+          #{bean.saleNum,jdbcType=DECIMAL},
+          #{bean.amount,jdbcType=DECIMAL},
+          #{bean.state,jdbcType=INTEGER},
+          #{bean.createUser,jdbcType=CHAR},
+          #{bean.createTime,jdbcType=TIMESTAMP}
+        )
       </foreach>
   </insert>
   <insert id="insertSelective" parameterType="com.hcloud.microserver.facade.carbon.entity.GoodsOrderDetail">

+ 19 - 0
common-core/src/main/java/com/hcloud/microserver/commoncore/base/BaseController.java

@@ -128,6 +128,25 @@ public class BaseController {
         return responseBase;
     }
 
+    /**
+     * 操作成功后,返回结果(前后端分离)
+     *
+     * @param
+     * @return
+     */
+    protected ResponseBase resultVOSuccess() {
+        ResultVO resultVO=new ResultVO();
+        resultVO.setCode(200);
+        resultVO.setMsg("操作成功!");
+        ResponseBase responseBase = new ResponseBase(resultVO.getData());
+        RetHead retHead = new RetHead();
+        retHead.setErrCode(resultVO.getCode().shortValue());
+        retHead.setErrMsg(resultVO.getMsg());
+        retHead.setTotal(resultVO.getCount());
+        responseBase.setRetHead(retHead);
+        return responseBase;
+    }
+
     protected ResponseBase responseSuccess(PageInfo pageInfo) {
         if (Objects.isNull(pageInfo)){ return responseSuccess(success(null, 0));}
         return responseSuccess(success(pageInfo.getList(),pageInfo.getTotal()));