Browse Source

Merge remote-tracking branch 'origin/dev' into dev

liql 4 years ago
parent
commit
edefd8713f
42 changed files with 1143 additions and 470 deletions
  1. 1 1
      carbon-admin/carbon-admin-service/src/main/java/com/hcloud/microserver/system/bank/service/impl/CompanyServiceImpl.java
  2. 1 1
      carbon-admin/carbon-admin-service/src/main/resources/com/hcloud/microserver/sys/service/dao/SysRolePermissionMapper.xml
  3. 8 0
      carbon-back/carbon-back-service/src/main/java/com/hcloud/microserver/system/bank/dao/ProductTypePriceMapper.java
  4. 3 0
      carbon-back/carbon-back-service/src/main/java/com/hcloud/microserver/system/bank/events/ProductTypePriceEvent.java
  5. 1 1
      carbon-back/carbon-back-service/src/main/java/com/hcloud/microserver/system/bank/service/impl/CompanyServiceImpl.java
  6. 14 0
      carbon-back/carbon-back-service/src/main/resources/carbon/ProductTypePriceMapper.xml
  7. 3 0
      carbon-h5/carbon-h5-common/src/main/java/com/hcloud/microserver/h5/facade/carbon/entity/GoodsCredentialInfo.java
  8. 5 4
      carbon-h5/carbon-h5-common/src/main/java/com/hcloud/microserver/h5/facade/carbon/forms/GoodsOrderInfoForm.java
  9. 8 0
      carbon-h5/carbon-h5-common/src/main/java/com/hcloud/microserver/h5/facade/carbon/vo/CustomerInfoVo.java
  10. 8 0
      carbon-h5/carbon-h5-common/src/main/java/com/hcloud/microserver/h5/facade/carbon/vo/GoodsOrderDetailVo.java
  11. 41 0
      carbon-h5/carbon-h5-common/src/main/java/com/hcloud/microserver/h5/facade/carbon/vo/GoodsOrderInfoVo.java
  12. 1 1
      carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/biz/WechatManagerComponent.java
  13. 13 0
      carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/bo/ContributionBO.java
  14. 5 0
      carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/bo/CredentialInfoBO.java
  15. 27 0
      carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/bo/MyCarbonValBO.java
  16. 21 0
      carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/bo/MyCarbonValInfoBO.java
  17. 1 1
      carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/bo/OrderInfoBO.java
  18. 42 23
      carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/controller/web/CustomerCarbonValController.java
  19. 7 1
      carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/controller/web/CustomerController.java
  20. 3 0
      carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/controller/web/GoodsManageTwoController.java
  21. 5 4
      carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/controller/web/OrderManagerController.java
  22. 7 6
      carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/controller/web/WechatAppPayController.java
  23. 25 0
      carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/dao/CustomerCarbonValMapper.java
  24. 2 0
      carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/dao/GoodsOrderInfoMapper.java
  25. 2 0
      carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/listens/CustomerCarbonValListener.java
  26. 11 0
      carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/service/CustomerCarbonValService.java
  27. 1 0
      carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/service/OrderDetailInfoService.java
  28. 1 1
      carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/service/impl/CompanyServiceImpl.java
  29. 42 22
      carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/service/impl/CredentialInfoServiceImpl.java
  30. 118 10
      carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/service/impl/CustomerCarbonValServiceImpl.java
  31. 11 2
      carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/service/impl/CustomerInfoServiceImpl.java
  32. 11 4
      carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/service/impl/OrderDetailInfoServiceImpl.java
  33. 61 38
      carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/service/impl/OrderInfoServiceImpl.java
  34. 26 0
      carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/task/AutoTask.java
  35. 52 0
      carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/util/CurrUserUtil.java
  36. 454 313
      carbon-h5/carbon-h5-service/src/main/resources/com/hcloud/microserver/h5/dao/CustomerCarbonValMapper.xml
  37. 4 1
      carbon-h5/carbon-h5-service/src/main/resources/com/hcloud/microserver/h5/dao/GoodsCredentialInfoMapper.xml
  38. 1 1
      carbon-h5/carbon-h5-service/src/main/resources/com/hcloud/microserver/h5/dao/GoodsManageMapper.xml
  39. 18 1
      carbon-h5/carbon-h5-service/src/main/resources/com/hcloud/microserver/h5/dao/GoodsOrderInfoMapper.xml
  40. 62 33
      common-core/src/main/java/com/hcloud/microserver/commoncore/util/TracedCodeUtils.java
  41. 12 0
      common-core/src/main/java/com/hcloud/microserver/commoncore/util/reflect/DateUtils.java
  42. 4 1
      sql/表结构变化语句/更新sql.sql

+ 1 - 1
carbon-admin/carbon-admin-service/src/main/java/com/hcloud/microserver/system/bank/service/impl/CompanyServiceImpl.java

@@ -28,7 +28,7 @@ public class CompanyServiceImpl implements CompanyService {
         int result = 0;
 
         String customerGuid = UUIDUtils.randomUUID();
-        customerInfo.setAccount(TracedCodeUtils.getCommonRandomCode());
+        customerInfo.setAccount(TracedCodeUtils.generateShortUuid());
         customerInfo.setPasswd(Md5Util.toMD5("000000"));
         customerInfo.setState(1);
         customerInfo.setIsEnable(1);

+ 1 - 1
carbon-admin/carbon-admin-service/src/main/resources/com/hcloud/microserver/sys/service/dao/SysRolePermissionMapper.xml

@@ -86,7 +86,7 @@
     <insert id="updateRolePermissionByPermisList">
         INSERT INTO sys_role_ref_sys_permission(GUID,REF_SYS_ROLE, REF_SYS_PERMISSION)
         VALUES
-        <foreach collection="list" item="item" index="index" separator=",">
+        TracedCodeUtils.generateShortUuid()reach collection="list" item="item" index="index" separator=",">
             (#{item.guid},#{item.refSysRole},#{item.refSysPermission})
         </foreach>
     </insert>

+ 8 - 0
carbon-back/carbon-back-service/src/main/java/com/hcloud/microserver/system/bank/dao/ProductTypePriceMapper.java

@@ -26,6 +26,14 @@ public interface ProductTypePriceMapper extends BaseMapper<ProductTypePriceWithB
      */
     int updateGoodsInfoPrice(ProductTypePriceWithBLOBs productTypePriceWithBLOBs);
 
+    /**
+     * 根据定价修改商品销售表价格
+     * lym
+     * @param productTypePriceWithBLOBs
+     * @return
+     */
+    int updateGoodsSaleInfoPrice(ProductTypePriceWithBLOBs productTypePriceWithBLOBs);
+
     /**
      * 查询最新的产品类别定价
      * lym

+ 3 - 0
carbon-back/carbon-back-service/src/main/java/com/hcloud/microserver/system/bank/events/ProductTypePriceEvent.java

@@ -38,5 +38,8 @@ public class ProductTypePriceEvent {
         int i = productTypePriceMapper.updateGoodsInfoPrice(productTypePrice);
         log.info("修改:"+productTypePrice.getTypeName()+"类别,id:{"+productTypePrice.getFkProductType()+"}共"
                 + i +"商品定价为"+productTypePrice.getPrice());
+        i = productTypePriceMapper.updateGoodsSaleInfoPrice(productTypePrice);
+        log.info("修改:"+productTypePrice.getTypeName()+"类别,id:{"+productTypePrice.getFkProductType()+"}共"
+                + i +"商品销售定价为"+productTypePrice.getPrice());
     }
 }

+ 1 - 1
carbon-back/carbon-back-service/src/main/java/com/hcloud/microserver/system/bank/service/impl/CompanyServiceImpl.java

@@ -28,7 +28,7 @@ public class CompanyServiceImpl implements CompanyService {
         int result = 0;
 
         String customerGuid = UUIDUtils.randomUUID();
-        customerInfo.setAccount(TracedCodeUtils.getCommonRandomCode());
+        customerInfo.setAccount(TracedCodeUtils.generateShortUuid());
         customerInfo.setPasswd(Md5Util.toMD5("000000"));
         customerInfo.setState(1);
         customerInfo.setIsEnable(1);

+ 14 - 0
carbon-back/carbon-back-service/src/main/resources/carbon/ProductTypePriceMapper.xml

@@ -240,6 +240,20 @@
        )
   </update>
 
+  <!-- 根据定价修改商品销售表价格 lym -->
+  <update id="updateGoodsSaleInfoPrice" parameterType="com.hcloud.microserver.system.facade.carbon.entity.ProductTypePriceWithBLOBs">
+    UPDATE t_goods_sale_info
+      SET sale_price = #{price,jdbcType=DECIMAL}
+      WHERE fk_goods_guid IN
+       ( SELECT tmp.guid FROM(SELECT a.guid,a.price,c.fk_product_type FROM t_goods_info a
+        LEFT JOIN t_goods_detail b ON a.guid = b.fk_goods_guid
+        LEFT JOIN t_product_info c ON b.fk_product_guid = c.guid
+        WHERE a.state = 1 AND b.state = 1 AND c.state = 1
+        AND  FIND_IN_SET(c.fk_product_type,#{fkProductType,jdbcType=LONGVARCHAR})
+        ) tmp
+       )
+  </update>
+
   <!-- 查询最新的产品类别定价 lym -->
   <select id="selectNewProductTypePrice" parameterType="String" resultMap="ResultMapWithBLOBs">
       SELECT <include refid="Base_Column_List"/>,<include refid="Blob_Column_List"/>

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

@@ -1,5 +1,7 @@
 package com.hcloud.microserver.h5.facade.carbon.entity;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
+
 import java.math.BigDecimal;
 import java.util.Date;
 
@@ -33,6 +35,7 @@ public class GoodsCredentialInfo {
 
     private String createUser;
 
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
     private Date createTime;
 
     private CustomerInfo customerInfo;

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

@@ -30,10 +30,6 @@ public class GoodsOrderInfoForm extends BaseForm {
 
     private Integer orderStatus;
 
-    /**
-     * 交易方式
-     */
-    private String tradeType;
     /**
      * 订单支付流水编号
      */
@@ -111,4 +107,9 @@ public class GoodsOrderInfoForm extends BaseForm {
      * 订单商品用途
      */
     private String goodsUse;
+
+    /**
+     * 0无效 1有效
+     */
+    private Integer state;
 }

+ 8 - 0
carbon-h5/carbon-h5-common/src/main/java/com/hcloud/microserver/h5/facade/carbon/vo/CustomerInfoVo.java

@@ -0,0 +1,8 @@
+package com.hcloud.microserver.h5.facade.carbon.vo;
+
+import com.hcloud.microserver.h5.facade.carbon.entity.CustomerInfo;
+import lombok.Data;
+
+@Data
+public class CustomerInfoVo extends CustomerInfo {
+}

+ 8 - 0
carbon-h5/carbon-h5-common/src/main/java/com/hcloud/microserver/h5/facade/carbon/vo/GoodsOrderDetailVo.java

@@ -0,0 +1,8 @@
+package com.hcloud.microserver.h5.facade.carbon.vo;
+
+import com.hcloud.microserver.h5.facade.carbon.entity.GoodsOrderDetail;
+import lombok.Data;
+
+@Data
+public class GoodsOrderDetailVo extends GoodsOrderDetail {
+}

+ 41 - 0
carbon-h5/carbon-h5-common/src/main/java/com/hcloud/microserver/h5/facade/carbon/vo/GoodsOrderInfoVo.java

@@ -0,0 +1,41 @@
+package com.hcloud.microserver.h5.facade.carbon.vo;
+
+import com.hcloud.microserver.h5.facade.carbon.entity.GoodsOrderInfo;
+import com.hcloud.microserver.h5.facade.carbon.forms.CustomerInfoForm;
+import com.hcloud.microserver.h5.facade.carbon.forms.GoodsInfoForm;
+import com.hcloud.microserver.h5.facade.carbon.forms.GoodsOrderDetailForm;
+import com.hcloud.microserver.h5.facade.carbon.forms.GoodsPayOrderForm;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+@Api("详情实体")
+public class GoodsOrderInfoVo extends GoodsOrderInfo {
+
+    /**
+     * 交易方式
+     */
+    @ApiModelProperty("交易方式(1.微信,2.支付宝,3,银联,4.线下支付)")
+    private Integer payChannel;
+
+    /**
+     * 商品订单详情
+     */
+    @ApiModelProperty("商品订单详情")
+    private List<GoodsOrderDetailVo> goodsOrderDetailForm;
+    /**
+     * 客户信息
+     */
+    @ApiModelProperty("商品订单详情")
+    private CustomerInfoForm customerInfoForm;
+
+    /**
+     * 客户信息
+     */
+    @ApiModelProperty("商品订单详情")
+    private GoodsPayOrderForm goodsPayOrderForm;
+
+}

+ 1 - 1
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/biz/WechatManagerComponent.java

@@ -139,7 +139,7 @@ public class WechatManagerComponent{
                 customerForm.setState(1);
                 customerForm.setCreateTime(new Date());
                 customerForm.setModifiedTime(new Date());
-                customerInfoForm.setAccount(TracedCodeUtils.getCommonRandomCode());
+                customerInfoForm.setAccount(TracedCodeUtils.generateShortUuid());
                 //customerInfoForm.setPasswd(Md5Util.toMD5(CodeUtil.getSearchId()));
                 customerInfoForm.setPasswd(Md5Util.toMD5("000000"));
                 int i = customerInfoService.saveCustomerInfoByChannelInfo(customerInfoForm);

+ 13 - 0
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/bo/ContributionBO.java

@@ -0,0 +1,13 @@
+package com.hcloud.microserver.h5.bo;
+
+import com.hcloud.microserver.h5.facade.carbon.entity.CustomerCarbonVal;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class ContributionBO extends CustomerCarbonVal {
+
+    private BigDecimal carbonAmount;
+
+}

+ 5 - 0
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/bo/CredentialInfoBO.java

@@ -53,4 +53,9 @@ public class CredentialInfoBO {
      * 订单金额
      */
     private BigDecimal OrderAmount;
+
+    /**
+     * 年度
+     */
+    private String year;
 }

+ 27 - 0
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/bo/MyCarbonValBO.java

@@ -0,0 +1,27 @@
+package com.hcloud.microserver.h5.bo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+@ApiModel("我的购碳分类")
+public class MyCarbonValBO {
+    /**
+     * 类型
+     */
+    @ApiModelProperty("类型")
+    private String type;
+    /**
+     * 文字
+     */
+    @ApiModelProperty("文字")
+    private String status;
+    /**
+     * 碳汇统计
+     */
+    @ApiModelProperty("碳汇统计")
+    private BigDecimal totalCarbonVal;
+}

+ 21 - 0
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/bo/MyCarbonValInfoBO.java

@@ -0,0 +1,21 @@
+package com.hcloud.microserver.h5.bo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+@Data
+@ApiModel("我的购碳分类")
+public class MyCarbonValInfoBO {
+    @ApiModelProperty("年份")
+    private Integer year;
+    @ApiModelProperty("总碳汇量")
+    private BigDecimal totalCarbonVal;
+    @ApiModelProperty("列表数据")
+    private List<MyCarbonValBO> data = new ArrayList<>();
+
+}

+ 1 - 1
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/bo/OrderInfoBO.java

@@ -43,7 +43,7 @@ public class OrderInfoBO {
     /**
      * 订单状态
      */
-    private String orderStatus;
+    private Integer orderStatus;
     /**
      * 购买时间
      */

+ 42 - 23
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/controller/web/CustomerCarbonValController.java

@@ -1,54 +1,73 @@
 package com.hcloud.microserver.h5.controller.web;
 
+import com.hcloud.microserver.commoncore.annotation.CurrentUser;
 import com.hcloud.microserver.commoncore.base.ResponseBase;
-import com.hcloud.microserver.commoncore.base.ResultVO;
 import com.hcloud.microserver.commoncore.enums.ResultEnum;
 import com.hcloud.microserver.commoncore.exception.GlobalException;
 import com.hcloud.microserver.commoncore.util.string.StringUtils;
-import com.hcloud.microserver.h5.common.BaseInfoDO;
+import com.hcloud.microserver.h5.bo.MyCarbonValBO;
+import com.hcloud.microserver.h5.bo.MyCarbonValInfoBO;
 import com.hcloud.microserver.h5.common.CarbonBaseController;
 import com.hcloud.microserver.h5.facade.carbon.forms.CustomerCarbonValRankForm;
+import com.hcloud.microserver.h5.facade.carbon.forms.CustomerInfoForm;
 import com.hcloud.microserver.h5.facade.carbon.vo.CustomerCarbonValRankVO;
 import com.hcloud.microserver.h5.service.CustomerCarbonValService;
+import com.hcloud.microserver.h5.service.CustomerService;
+import com.hcloud.microserver.h5.util.CurrUserUtil;
 import io.swagger.annotations.*;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
-import javax.validation.Valid;
+import java.util.List;
 
 @RestController
 @RequestMapping("/wap/carbonVal")
-@Api(tags = "购碳量信息接口",description = "购碳量信息接口")
+@Api(tags = "购碳量信息接口", description = "购碳量信息接口")
 public class CustomerCarbonValController extends CarbonBaseController {
 
     @Autowired
     private CustomerCarbonValService customerCarbonValService;
+    @Autowired
+    private CustomerService customerService;
 
-    @ApiOperation(value = "排行榜",notes = "排行榜")
+    @ApiOperation(value = "排行榜", notes = "排行榜")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "type",value = "类型 1:企业排行榜 2:个人排行榜", dataType = "int")
+            @ApiImplicitParam(name = "type", value = "类型 1:个人排行榜 2:企业排行榜", dataType = "int")
     })
-    @ApiResponse(code =0,message = "查询成功")
-    @PostMapping("/getCustomerCarbonValRank")
-    public ResponseBase getCustomerCarbonValRank(@RequestBody @Valid CustomerCarbonValRankForm form){
-        if (form.getType() < 1 || form.getType() > 2){
-            throw new GlobalException(ResultEnum.FAILURE.getCode(),"查询排行类型错误!");
-        }
-
-        BaseInfoDO baseInfoDO = this.initiSaveObject();
-        if (baseInfoDO == null) {
-            return responseError(new ResultVO(ResultEnum.TOKEN_EXPIRED));
+    @ApiResponse(code = 0, message = "查询成功")
+    @GetMapping("/getCustomerCarbonValRank")
+    public ResponseBase getCustomerCarbonValRank(@RequestParam("type") Integer type) {
+        if (type < 1 || type > 2) {
+            throw new GlobalException(ResultEnum.FAILURE.getCode(), "查询排行类型错误!");
         }
-        if (StringUtils.isEmpty(form.getCustomerId())){
-            form.setCustomerId(baseInfoDO.getCustomerId());
-        }
-        if (form.getCustomerType() == null){
-            form.setCustomerType(baseInfoDO.getCustomerType());
+        CustomerCarbonValRankForm form = new CustomerCarbonValRankForm();
+        form.setType(type);
+        //获取是否有登录用户
+        CustomerInfoForm customerInfo = CurrUserUtil.getCurrentMember();
+        if (customerInfo != null) {
+            if (StringUtils.isEmpty(form.getCustomerId())) {
+                form.setCustomerId(customerInfo.getGuid());
+            }
+            if (form.getCustomerType() == null) {
+                form.setCustomerType(customerInfo.getCustomerType());
+            }
         }
+
         CustomerCarbonValRankVO vo = customerCarbonValService.getCustomerCarbonValRankList(form);
         return responseResultSuccess(vo);
     }
+
+    @ApiOperation(value = "我的购碳详情", notes = "我的购碳详情")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "year", value = "年份", dataType = "int")
+    })
+    @ApiResponse(code = 0, message = "查询成功")
+    @GetMapping("/myCarbonVal")
+    public ResponseBase<MyCarbonValInfoBO> myCarbonVal(@RequestParam("year") Integer year) {
+        MyCarbonValInfoBO data = customerCarbonValService.myCarbonVal(year);
+        return responseResultSuccess(data);
+    }
 }

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

@@ -5,6 +5,7 @@ import com.hcloud.microserver.h5.forms.CompanyValidateForm;
 import com.hcloud.microserver.h5.forms.LoginForm;
 import com.hcloud.microserver.h5.forms.PersonValidateForm;
 import com.hcloud.microserver.h5.forms.SmallCustomer;
+import com.hcloud.microserver.h5.service.CustomerCarbonValService;
 import com.hcloud.microserver.h5.service.CustomerCompanyInfoService;
 import com.hcloud.microserver.h5.service.CustomerInfoService;
 import com.hcloud.microserver.h5.service.CustomerService;
@@ -24,6 +25,7 @@ import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.core.ValueOperations;
 import org.springframework.web.bind.annotation.*;
 
+import java.math.BigDecimal;
 import java.security.Principal;
 import java.util.Date;
 import java.util.HashMap;
@@ -78,6 +80,9 @@ public class CustomerController extends BaseController {
         return responseResultSuccess();
     }
 
+    @Autowired
+    private CustomerCarbonValService customerCarbonValService;
+
     @ApiOperation(value = "获取爱心用户登录信息", notes = "获取爱心用户登录信息,通过token")
     @ApiResponse(code = 0, message = "查询成功")
     @GetMapping("/getCustomerByToken")
@@ -87,7 +92,8 @@ public class CustomerController extends BaseController {
             responseError(new ResultVO(ResultEnum.UNAUTHORIZED));
         }
         CustomerInfoForm customerInfo = customerService.getCurrentMember();
-        Integer isCompany = customerInfo.getIsCompany();
+        BigDecimal  carbonAmount = customerCarbonValService.selectCarbonAmountByCustomerId(customerInfo.getGuid());
+        customerInfo.setCarbonAmount(carbonAmount);
 
         return responseResultSuccess(customerInfo);
     }

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

@@ -53,6 +53,9 @@ public class GoodsManageTwoController extends BaseController {
     @GetMapping("/getGoodsInfoByCarbonNum")
     @AuthCarbonValidate
     public ResponseBase getGoodsInfoByCarbonNum(@RequestParam("carbonNum") Integer carbonNum){
+        if (carbonNum == null){
+            throw new GlobalException(ResultEnum.FAILURE.getCode(),"请输入购碳量");
+        }
         if (carbonNum > 9999999){
             throw new GlobalException(ResultEnum.FAILURE.getCode(),"购碳量过大");
         }

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

@@ -7,6 +7,7 @@ import com.hcloud.microserver.h5.facade.carbon.entity.from.CreateOrderFrom;
 import com.hcloud.microserver.h5.bo.CredentialInfoBO;
 import com.hcloud.microserver.h5.common.BaseInfoDO;
 import com.hcloud.microserver.h5.common.CarbonBaseController;
+import com.hcloud.microserver.h5.facade.carbon.vo.GoodsOrderInfoVo;
 import com.hcloud.microserver.h5.forms.OrderQueryForm;
 import com.hcloud.microserver.h5.service.*;
 import com.hcloud.microserver.commoncore.annotation.AuthCarbonValidate;
@@ -98,7 +99,7 @@ public class OrderManagerController extends CarbonBaseController {
     @ApiOperation(value = "查询爱心用户订单信息", notes = "分类查询爱心用户订单")
     @GetMapping("/info")
     @AuthCarbonValidate
-    public ResponseBase info(@RequestParam String orderId) {
+    public ResponseBase<GoodsOrderInfoVo> info(@RequestParam String orderId) {
         GoodsOrderInfoForm orderInfoBO = orderDetailInfoService.info(orderId);
         return resultVOSuccess(orderInfoBO);
     }
@@ -123,11 +124,11 @@ public class OrderManagerController extends CarbonBaseController {
     @PostMapping("/searchCredentialList")
     @AuthCarbonValidate
     public ResponseBase searchCredentialInfo(@RequestBody GoodsCredentialInfoForm goodsCredentialInfoForm) {
-        BaseInfoDO baseInfoDO = this.initiSaveObject();
-        if (baseInfoDO == null) {
+        CustomerInfoForm customerInfo = customerService.getCurrentMember();
+        if (customerInfo == null) {
             return responseError(new ResultVO(ResultEnum.TOKEN_EXPIRED));
         }
-        goodsCredentialInfoForm.setFkCustomerId(baseInfoDO.getCustomerId());
+        goodsCredentialInfoForm.setFkCustomerId(customerInfo.getGuid());
         PageInfo pageInfo = credentialInfoService.searchCredentialByPage(goodsCredentialInfoForm);
         ResultVO resultVO = success(pageInfo.getList(), pageInfo.getTotal());
         return responseSuccess(resultVO);

+ 7 - 6
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/controller/web/WechatAppPayController.java

@@ -85,12 +85,13 @@ public class WechatAppPayController extends BaseController {
         //元转成分
         money = money.multiply(new BigDecimal(100));
         int i = money.intValue();
-        if ("test".equals(tradeType)) {
-            //测试环境一分钱
-            orderRequest.setTotalFee(1);
-        } else {
-            orderRequest.setTotalFee(i);
-        }
+//        if ("test".equals(tradeType)) {
+//            //测试环境一分钱
+//            orderRequest.setTotalFee(1);
+//        } else {
+//
+//        }
+        orderRequest.setTotalFee(i);
         //终端ip
         String ipAddress = getIpAddress(request);
         orderRequest.setSpbillCreateIp(ipAddress);

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

@@ -1,12 +1,18 @@
 package com.hcloud.microserver.h5.dao;
 
+import com.hcloud.microserver.h5.bo.ContributionBO;
+import com.hcloud.microserver.h5.bo.MyCarbonValBO;
 import com.hcloud.microserver.h5.facade.carbon.entity.CustomerCarbonVal;
 import com.hcloud.microserver.h5.facade.carbon.entity.CustomerCarbonValExample;
 import com.hcloud.microserver.h5.facade.carbon.forms.CustomerCarbonValRankForm;
+import org.apache.ibatis.annotations.MapKey;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.math.BigDecimal;
 import java.util.List;
+import java.util.Map;
+
 @Mapper
 public interface CustomerCarbonValMapper {
     int countByExample(CustomerCarbonValExample example);
@@ -38,4 +44,23 @@ public interface CustomerCarbonValMapper {
      * @return
      */
     List<CustomerCarbonValRankForm> getCustomerCarbonValRankList(CustomerCarbonValRankForm form);
+
+    /**
+     * 统计个人总碳汇量
+     * @param guid
+     * @return
+     */
+    BigDecimal selectCarbonAmountByCustomerId(@Param("guid") String guid);
+
+    @MapKey("tCustomerId")
+    Map<String, ContributionBO> totalcarbonVal(@Param("year") Integer year);
+
+    @MapKey("tCustomerId")
+    Map<String, ContributionBO> subcarbonVal(@Param("year") Integer year);
+
+    ContributionBO contribution(@Param("customerid") String customerid,@Param("year") Integer year);
+
+    void insertSelectiveList(@Param("list") List<CustomerCarbonVal> list);
+
+    List<MyCarbonValBO> myCarbonVal(@Param("year") Integer year,@Param("guid") String guid);
 }

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

@@ -46,4 +46,6 @@ public interface GoodsOrderInfoMapper extends BaseMapper<GoodsOrderInfo,String>
     int updateOrderBelongInfo(@Param("oldId") String oldCustomerId ,@Param("newId") String newCustomerId);
 
     OrderInfoBO info(@Param("guid")String guid);
+
+    Integer payChannel(@Param("guid")String guid);
 }

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

@@ -53,6 +53,8 @@ public class CustomerCarbonValListener {
         record.setRemarks("购买碳汇数据");
         //获取年份
         record.setYearTime(getYear());
+        //创建人
+        record.setCreateUser(goodsOrderInfo.getFkCustomerGuid());
         customerCarbonValMapper.insertSelective(record);
     }
 

+ 11 - 0
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/service/CustomerCarbonValService.java

@@ -1,8 +1,13 @@
 package com.hcloud.microserver.h5.service;
 
+import com.hcloud.microserver.h5.bo.MyCarbonValBO;
+import com.hcloud.microserver.h5.bo.MyCarbonValInfoBO;
 import com.hcloud.microserver.h5.facade.carbon.forms.CustomerCarbonValRankForm;
 import com.hcloud.microserver.h5.facade.carbon.vo.CustomerCarbonValRankVO;
 
+import java.math.BigDecimal;
+import java.util.List;
+
 public interface CustomerCarbonValService {
 
     /**
@@ -12,4 +17,10 @@ public interface CustomerCarbonValService {
      * @return
      */
     CustomerCarbonValRankVO getCustomerCarbonValRankList(CustomerCarbonValRankForm form);
+
+    BigDecimal selectCarbonAmountByCustomerId(String guid);
+
+    void contribution();
+
+    MyCarbonValInfoBO myCarbonVal(Integer year);
 }

+ 1 - 0
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/service/OrderDetailInfoService.java

@@ -4,6 +4,7 @@ import com.hcloud.microserver.commoncore.base.BaseServie;
 import com.hcloud.microserver.h5.facade.carbon.entity.GoodsOrderDetail;
 import com.hcloud.microserver.h5.facade.carbon.forms.GoodsOrderDetailForm;
 import com.hcloud.microserver.h5.facade.carbon.forms.GoodsOrderInfoForm;
+import com.hcloud.microserver.h5.facade.carbon.vo.GoodsOrderInfoVo;
 
 import java.util.List;
 

+ 1 - 1
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/service/impl/CompanyServiceImpl.java

@@ -28,7 +28,7 @@ public class CompanyServiceImpl implements CompanyService {
         int result = 0;
 
         String customerGuid = UUIDUtils.randomUUID();
-        customerInfo.setAccount(TracedCodeUtils.getCommonRandomCode());
+        customerInfo.setAccount(TracedCodeUtils.generateShortUuid());
         customerInfo.setPasswd(Md5Util.toMD5("000000"));
         customerInfo.setState(1);
         customerInfo.setIsEnable(1);

+ 42 - 22
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/service/impl/CredentialInfoServiceImpl.java

@@ -13,6 +13,7 @@ import com.hcloud.microserver.h5.facade.carbon.entity.GoodsCredentialInfo;
 import com.hcloud.microserver.h5.facade.carbon.entity.GoodsOrderInfo;
 import com.hcloud.microserver.h5.facade.carbon.forms.GoodsCredentialInfoForm;
 import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
 
 import javax.annotation.Resource;
 import java.text.SimpleDateFormat;
@@ -40,7 +41,6 @@ public class CredentialInfoServiceImpl implements CredentialInfoService {
     private GoodsOrderInfoMapper goodsOrderInfoMapper;
 
 
-
     /**
      * 生成证书记录
      *
@@ -49,15 +49,15 @@ public class CredentialInfoServiceImpl implements CredentialInfoService {
      */
     @Override
     public int saveCredentialInfo(String orderId) {
-        if(null!=orderId && !"".equals(orderId)){
+        if (null != orderId && !"".equals(orderId)) {
             GoodsCredentialInfoForm goodsCredentialInfoForm = new GoodsCredentialInfoForm();
             //查询订单信息
             GoodsOrderInfo goodsOrderInfo = goodsOrderInfoMapper.selectByPrimaryKey(orderId);
             //查询农户信息
-            List<CredentialInfoBO> list =  goodsCredentialInfoMapper.getCredentialFarmerInfoByOrderId(orderId);
-           //获取最大证书最大编码
+            List<CredentialInfoBO> list = goodsCredentialInfoMapper.getCredentialFarmerInfoByOrderId(orderId);
+            //获取最大证书最大编码
             Integer currentNum = getCurrentCode();
-            String maxCode = BusinessCodeRule.notYearCodeRule(CODE_PREFIX,currentNum,15);
+            String maxCode = BusinessCodeRule.notYearCodeRule(CODE_PREFIX, currentNum, 15);
             goodsCredentialInfoForm.setFkOrderId(orderId);
             goodsCredentialInfoForm.setFkCustomerId(goodsOrderInfo.getFkCustomerGuid());
             goodsCredentialInfoForm.setBuyDate(new Date());
@@ -65,15 +65,31 @@ public class CredentialInfoServiceImpl implements CredentialInfoService {
             goodsCredentialInfoForm.setCredentialNo(maxCode);
             String farmerNames = "";
             String farmerAreas = "";
-            Integer farmerCount=0;
-            if(null!=list && list.size()>0){
-               for (CredentialInfoBO bo:list) {
-                   if(Objects.isNull(bo)){continue;}
-                   Integer temp = bo.getFarmerNum()==null?0:bo.getFarmerNum();
-                   farmerNames+=bo.getFarmerName()+",";
-                   farmerAreas+=bo.getFarmerVillage()+",";
-                   farmerCount+=temp;
-               }
+            Integer farmerCount = 0;
+            if (null != list && list.size() > 0) {
+                for (CredentialInfoBO bo : list) {
+                    if (Objects.isNull(bo)) {
+                        continue;
+                    }
+                    Integer temp = bo.getFarmerNum() == null ? 0 : bo.getFarmerNum();
+                    String farmerName = bo.getFarmerName();
+                    if (!StringUtils.isEmpty(farmerName)) {
+                        farmerNames += farmerName + ",";
+                    }
+                    String farmerVillage = bo.getFarmerVillage();
+                    if (!StringUtils.isEmpty(farmerVillage)) {
+                        farmerAreas += farmerVillage + ",";
+                    }
+                    farmerCount += temp;
+                }
+                //去除最后一个,号
+                if (farmerNames.length() > 0) {
+                    farmerNames = farmerNames.substring(0, farmerNames.length() - 1);
+                }
+                //去除最后一个,号
+                if (farmerAreas.length() > 0) {
+                    farmerAreas = farmerAreas.substring(0, farmerAreas.length() - 1);
+                }
                 goodsCredentialInfoForm.setFarmerNames(farmerNames);
                 goodsCredentialInfoForm.setProductAddress(farmerAreas);
                 goodsCredentialInfoForm.setFarmerCount(farmerCount);
@@ -87,13 +103,14 @@ public class CredentialInfoServiceImpl implements CredentialInfoService {
 
     /**
      * 分页查询用户证书信息
+     *
      * @param goodsCredentialInfoForm
      * @return
      */
     @Override
     public PageInfo searchCredentialByPage(GoodsCredentialInfoForm goodsCredentialInfoForm) {
         String customId = goodsCredentialInfoForm.getFkCustomerId();
-        PageHelper.startPage(goodsCredentialInfoForm.getPageNo(),goodsCredentialInfoForm.getPageSize());
+        PageHelper.startPage(goodsCredentialInfoForm.getPageNo(), goodsCredentialInfoForm.getPageSize());
         List<GoodsCredentialInfo> list = goodsCredentialInfoMapper.getCredentialInfoByCustomerId(customId);
         return new PageInfo(list);
     }
@@ -111,12 +128,15 @@ public class CredentialInfoServiceImpl implements CredentialInfoService {
 
     /**
      * 获取当前编码流水号的数字形式
+     *
      * @return
      */
-    private Integer getCurrentCode(){
+    private Integer getCurrentCode() {
         StringBuffer sbb = new StringBuffer();
         String maxCode = goodsCredentialInfoMapper.getMaxCode();
-        if(maxCode==null){return 500;}
+        if (maxCode == null) {
+            return 500;
+        }
         sbb.append(CODE_PREFIX);
         String currentNum = maxCode.substring(sbb.toString().length());
         return Integer.valueOf(currentNum);
@@ -132,7 +152,7 @@ public class CredentialInfoServiceImpl implements CredentialInfoService {
     public int save(GoodsCredentialInfoForm record) {
         record.setGuid(GetUUID.getUUID());
         record.setModifiedTime(new Date());
-        GoodsCredentialInfo goodsCredentialInfo = BeanCopyUtil.convertBean(record,GoodsCredentialInfo.class);
+        GoodsCredentialInfo goodsCredentialInfo = BeanCopyUtil.convertBean(record, GoodsCredentialInfo.class);
         return goodsCredentialInfoMapper.insert(goodsCredentialInfo);
     }
 
@@ -140,19 +160,19 @@ public class CredentialInfoServiceImpl implements CredentialInfoService {
     public int saveSelective(GoodsCredentialInfoForm record) {
         record.setGuid(GetUUID.getUUID());
         record.setModifiedTime(new Date());
-        GoodsCredentialInfo goodsCredentialInfo = BeanCopyUtil.convertBean(record,GoodsCredentialInfo.class);
+        GoodsCredentialInfo goodsCredentialInfo = BeanCopyUtil.convertBean(record, GoodsCredentialInfo.class);
         return goodsCredentialInfoMapper.insertSelective(goodsCredentialInfo);
     }
 
     @Override
     public GoodsCredentialInfoForm queryByPrimaryKey(String guid) {
         GoodsCredentialInfo goodsCredentialInfo = goodsCredentialInfoMapper.selectByPrimaryKey(guid);
-        return BeanCopyUtil.convertBean(goodsCredentialInfo,GoodsCredentialInfoForm.class);
+        return BeanCopyUtil.convertBean(goodsCredentialInfo, GoodsCredentialInfoForm.class);
     }
 
     @Override
     public int modifyByPrimaryKeySelective(GoodsCredentialInfoForm record) {
-        GoodsCredentialInfo goodsCredentialInfo = BeanCopyUtil.convertBean(record,GoodsCredentialInfo.class);
+        GoodsCredentialInfo goodsCredentialInfo = BeanCopyUtil.convertBean(record, GoodsCredentialInfo.class);
         return goodsCredentialInfoMapper.updateByPrimaryKeySelective(goodsCredentialInfo);
     }
 
@@ -164,7 +184,7 @@ public class CredentialInfoServiceImpl implements CredentialInfoService {
 
     @Override
     public int modifyByPrimaryKey(GoodsCredentialInfoForm record) {
-        GoodsCredentialInfo goodsCredentialInfo = BeanCopyUtil.convertBean(record,GoodsCredentialInfo.class);
+        GoodsCredentialInfo goodsCredentialInfo = BeanCopyUtil.convertBean(record, GoodsCredentialInfo.class);
         return goodsCredentialInfoMapper.updateByPrimaryKey(goodsCredentialInfo);
     }
 }

+ 118 - 10
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/service/impl/CustomerCarbonValServiceImpl.java

@@ -1,13 +1,25 @@
 package com.hcloud.microserver.h5.service.impl;
 
+import com.hcloud.microserver.commoncore.util.UUIDUtils;
+import com.hcloud.microserver.commoncore.util.string.StringUtils;
+import com.hcloud.microserver.h5.bo.ContributionBO;
+import com.hcloud.microserver.h5.bo.MyCarbonValBO;
+import com.hcloud.microserver.h5.bo.MyCarbonValInfoBO;
 import com.hcloud.microserver.h5.dao.CustomerCarbonValMapper;
+import com.hcloud.microserver.h5.facade.carbon.entity.CustomerCarbonVal;
 import com.hcloud.microserver.h5.facade.carbon.forms.CustomerCarbonValRankForm;
+import com.hcloud.microserver.h5.facade.carbon.forms.CustomerInfoForm;
 import com.hcloud.microserver.h5.facade.carbon.vo.CustomerCarbonValRankVO;
 import com.hcloud.microserver.h5.service.CustomerCarbonValService;
+import com.hcloud.microserver.h5.service.CustomerService;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
-import java.util.List;
+import java.math.BigDecimal;
+import java.util.*;
 
 @Service
 public class CustomerCarbonValServiceImpl implements CustomerCarbonValService {
@@ -18,16 +30,112 @@ public class CustomerCarbonValServiceImpl implements CustomerCarbonValService {
     @Override
     public CustomerCarbonValRankVO getCustomerCarbonValRankList(CustomerCarbonValRankForm form) {
         List<CustomerCarbonValRankForm> list = customerCarbonValMapper.getCustomerCarbonValRankList(form);
-        if (list != null && list.size() > 0){
-            CustomerCarbonValRankVO vo = new CustomerCarbonValRankVO();
-            form.setCurrCustomerRank(true); //查询当前客户排名
-            List<CustomerCarbonValRankForm> currCustomerRankList = customerCarbonValMapper.getCustomerCarbonValRankList(form);
-            if (currCustomerRankList != null && currCustomerRankList.size() > 0){
-                vo.setCurrCustomerRankForm(currCustomerRankList.get(0));
+        CustomerCarbonValRankVO vo = new CustomerCarbonValRankVO();
+        if (list != null && list.size() > 0 && StringUtils.isNotEmpty(form.getCustomerId())) {
+            if ((form.getType() == 1 && form.getCustomerType() == 1)  //查询当前客户排名
+                    || (form.getType() == 2 && form.getCustomerType() > 1)) {
+                form.setCurrCustomerRank(true);
+                List<CustomerCarbonValRankForm> currCustomerRankList = customerCarbonValMapper.getCustomerCarbonValRankList(form);
+                if (currCustomerRankList != null && currCustomerRankList.size() > 0)
+                    vo.setCurrCustomerRankForm(currCustomerRankList.get(0));
             }
-            vo.setList(list);
-            return vo;
         }
-        return null;
+        vo.setList(list);
+        return vo;
+    }
+
+    @Override
+    public BigDecimal selectCarbonAmountByCustomerId(String guid) {
+        return customerCarbonValMapper.selectCarbonAmountByCustomerId(guid);
+    }
+
+    @Transactional
+    @Override
+    public void contribution() {
+        Integer year = getYear();
+        //获取前3年的数据进行
+        Integer newYear = year - 4;
+        //获取总碳汇量
+        Map<String, ContributionBO> sumCarbonAmount = customerCarbonValMapper.totalcarbonVal(newYear);
+        //获取消去碳汇量
+        Map<String, ContributionBO> subcarbonVal = customerCarbonValMapper.subcarbonVal(newYear);
+
+        List<CustomerCarbonVal> customerCarbonValList = new ArrayList<>();
+        for (String tCustomerId : sumCarbonAmount.keySet()) {
+
+            ContributionBO contribution = customerCarbonValMapper.contribution(tCustomerId, newYear);
+            //如果以及贡献过了就不贡献了
+            if(org.springframework.util.StringUtils.isEmpty(contribution)){
+                //获取单独一个人的总碳汇量
+                BigDecimal totalcarbonAmount = new BigDecimal(0);
+                ContributionBO contributionRe = sumCarbonAmount.get(tCustomerId);
+                totalcarbonAmount = contributionRe.getCarbonAmount();
+                //获取使用的碳汇量
+                BigDecimal subCarbonAmount = new BigDecimal(0);
+                ContributionBO subcarbonValRe = subcarbonVal.get(tCustomerId);
+                //获取不到不赋值
+                if (!org.springframework.util.StringUtils.isEmpty(subcarbonValRe)) {
+                    subCarbonAmount = subcarbonValRe.getCarbonAmount();
+                }
+                //得到剩余碳汇量
+                BigDecimal subtract = totalcarbonAmount.subtract(subCarbonAmount);
+                //还剩余0就不做共享
+                int i = subtract.compareTo(BigDecimal.ZERO);
+                if (i != 0) {
+                    CustomerCarbonVal customerCarbonVal = new CustomerCarbonVal();
+                    BeanUtils.copyProperties(contributionRe, customerCarbonVal);
+                    String guid = UUIDUtils.randomUUID();
+                    customerCarbonVal.setGuid(guid);
+                    customerCarbonVal.setCarbonVal(subtract);
+                    //使用碳汇量
+                    customerCarbonVal.setStatus(0);
+                    //类型 1购买碳汇 2企业碳中和 3大型活动碳中和 4碳履约 5为重庆市碳排放量做贡献
+                    customerCarbonVal.setType(5);
+                    //来源表
+                    customerCarbonVal.setTbGuid(guid);
+                    //
+                    customerCarbonVal.setYearTime(newYear);
+                    customerCarbonVal.setTbName("t_customer_carbon_val");
+                    //为重庆排放做贡献
+                    customerCarbonVal.setRemarks("为重庆市碳排放量做贡献");
+                    customerCarbonVal.setCreateUser(customerCarbonVal.gettCustomerId());
+                    customerCarbonVal.setCreateTime(new Date());
+                    customerCarbonValList.add(customerCarbonVal);
+                }
+            }
+
+
+
+        }
+        if (customerCarbonValList.size() != 0) {
+            customerCarbonValMapper.insertSelectiveList(customerCarbonValList);
+        }
+    }
+
+    public Integer getYear() {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(new Date());
+        return calendar.get(Calendar.YEAR);
+    }
+
+    @Autowired
+    private CustomerService customerService;
+
+    @Override
+    public MyCarbonValInfoBO myCarbonVal(Integer year) {
+        MyCarbonValInfoBO myCarbonValInfoBO = new MyCarbonValInfoBO();
+        //获取登陆人信息
+        CustomerInfoForm customerInfo = customerService.getCurrentMember();
+        String guid = customerInfo.getGuid();
+
+        List<MyCarbonValBO> myCarbonValBOS = customerCarbonValMapper.myCarbonVal(year, guid);
+        BigDecimal totalCarbonVal = new BigDecimal(0);
+        for (MyCarbonValBO myCarbonValBO : myCarbonValBOS) {
+            totalCarbonVal = totalCarbonVal.add(myCarbonValBO.getTotalCarbonVal());
+        }
+        myCarbonValInfoBO.setYear(year);
+        myCarbonValInfoBO.setData(myCarbonValBOS);
+        myCarbonValInfoBO.setTotalCarbonVal(totalCarbonVal);
+        return myCarbonValInfoBO;
     }
 }

+ 11 - 2
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/service/impl/CustomerInfoServiceImpl.java

@@ -327,6 +327,15 @@ public class CustomerInfoServiceImpl implements CustomerInfoService {
         if (customerInfo == null) {
             Asserts.fail("登录失败");
         }
+
+        CustomerInfoForm customerInfoBo = customerInfo.getCustomerInfo();
+        if(!org.springframework.util.StringUtils.isEmpty(customerInfoBo)){
+
+            Integer isEnable = customerInfoBo.getIsEnable();
+            if(isEnable.intValue()==0){
+                Asserts.fail("用户被禁用");
+            }
+        }
         UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(customerInfo, null, customerInfo.getAuthorities());
         SecurityContextHolder.getContext().setAuthentication(authentication);
         String token = jwtTokenUtil.generateToken(customerInfo);
@@ -374,8 +383,8 @@ public class CustomerInfoServiceImpl implements CustomerInfoService {
             //默认密码
             String s = Md5Util.toMD5("000000");
             customerInfo.setPasswd(s);
-            //设置登陆账号
-            String commonRandomCode = TracedCodeUtils.getCommonRandomCode();
+            //设置登陆账号 默认给一个
+            String commonRandomCode = TracedCodeUtils.generateShortUuid();
             customerInfo.setAccount(commonRandomCode);
             customerInfoMapper.insertSelective(customerInfo);
         } else {

+ 11 - 4
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/service/impl/OrderDetailInfoServiceImpl.java

@@ -5,14 +5,17 @@ import com.hcloud.microserver.h5.bo.OrderDetailInfoBO;
 import com.hcloud.microserver.h5.bo.OrderInfoBO;
 import com.hcloud.microserver.h5.dao.GoodsOrderDetailMapper;
 import com.hcloud.microserver.h5.dao.GoodsOrderInfoMapper;
+import com.hcloud.microserver.h5.facade.carbon.vo.GoodsOrderInfoVo;
 import com.hcloud.microserver.h5.service.OrderDetailInfoService;
 import com.hcloud.microserver.commoncore.util.BeanCopyUtil;
 import com.hcloud.microserver.commoncore.util.GetUUID;
 import com.hcloud.microserver.h5.facade.carbon.entity.GoodsOrderDetail;
 import com.hcloud.microserver.h5.facade.carbon.forms.GoodsOrderDetailForm;
+import io.swagger.models.auth.In;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
 
 import javax.annotation.Resource;
 import java.util.List;
@@ -114,11 +117,15 @@ public class OrderDetailInfoServiceImpl implements OrderDetailInfoService {
 
     @Override
     public GoodsOrderInfoForm info(String guid) {
-        OrderInfoBO info = goodsOrderInfoMapper.info(guid);
         GoodsOrderInfoForm goodsOrderInfoForm=new GoodsOrderInfoForm();
-        BeanUtils.copyProperties(info,goodsOrderInfoForm);
-        List<GoodsOrderDetailForm> detailFormList = orderDetailInfoService.getOrderDetailListByOrderId(guid);
-        goodsOrderInfoForm.setGoodsOrderDetailForm(detailFormList);
+        OrderInfoBO info = goodsOrderInfoMapper.info(guid);
+        if(!StringUtils.isEmpty(info)){
+            BeanUtils.copyProperties(info,goodsOrderInfoForm);
+            List<GoodsOrderDetailForm> detailFormList = orderDetailInfoService.getOrderDetailListByOrderId(guid);
+            goodsOrderInfoForm.setGoodsOrderDetailForm(detailFormList);
+        }
+        Integer payChannel  = goodsOrderInfoMapper.payChannel(guid);
+        goodsOrderInfoForm.setPayChannel(payChannel);
         return goodsOrderInfoForm;
     }
 

+ 61 - 38
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/service/impl/OrderInfoServiceImpl.java

@@ -284,28 +284,31 @@ public class OrderInfoServiceImpl implements OrderInfoService {
                 //更新订单信息
                 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();
+                if(!StringUtils.isEmpty(goodsOrderInfo)){
+                    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(this, orderId));
+                        //生成购买碳汇数据
+                        applicationContext.publishEvent(new CustomerCarbonValEvent(this, orderId));
+
+                        return i;
                     }
-                    //更新农户收入信息
-                    updateFarmerSaleInfo(orderId);
-                    //生成证书信息
-                    applicationContext.publishEvent(new CredentialInfoEvent(this, orderId));
-                    //生成购买碳汇数据
-                    applicationContext.publishEvent(new CustomerCarbonValEvent(this, orderId));
-
-                    return i;
-                } else {
-                    throw new RuntimeException();
+                }else{
+                    log.info("订单不存在无法更新!");
                 }
+
             }
         }
 
@@ -345,11 +348,11 @@ public class OrderInfoServiceImpl implements OrderInfoService {
     public int rollbackOrderInfo(String orderId) {
         GoodsOrderInfo goodsOrderInfo = goodsOrderInfoMapper.selectByPrimaryKey(orderId);
         Integer orderStatus = goodsOrderInfo.getOrderStatus();
-        if(orderStatus.intValue() !=1){
+        if (orderStatus.intValue() != 1) {
             throw new RuntimeException("该订单已支付款订单无法取消!");
         }
         Integer state = goodsOrderInfo.getState();
-        if(state.intValue() ==0){
+        if (state.intValue() == 0) {
             throw new RuntimeException("该订单为无效订单!");
         }
         goodsOrderInfo.setState(0);
@@ -365,7 +368,7 @@ public class OrderInfoServiceImpl implements OrderInfoService {
                 BigDecimal saleCarbon = bean.getSaleNum();
                 String goodsGuid = bean.getFkGoodsGuid();
                 GoodsSaleInfoForm goodsSaleInfoForm = orderSaleInfoService.getGoodsSaleInfoByGoodsId(goodsGuid);
-                if(!StringUtils.isEmpty(goodsSaleInfoForm)){
+                if (!StringUtils.isEmpty(goodsSaleInfoForm)) {
                     BigDecimal saledCarbonSkin = goodsSaleInfoForm.getSaledCarbonSkin().subtract(saleCarbon);
                     BigDecimal unSaleCarbonSkin = goodsSaleInfoForm.getUnsaledCarbonSkin().add(saleCarbon);
                     goodsSaleInfoForm.setSaledCarbonSkin(saledCarbonSkin);
@@ -532,7 +535,7 @@ public class OrderInfoServiceImpl implements OrderInfoService {
         if (customerInfo == null) {
             throw new RuntimeException("获取登陆信息失败");
         }
-        if(customerInfo.getIsCompany() == 1){
+        if (customerInfo.getIsCompany() == 1) {
             throw new RuntimeException("不是自然人无法购买商品!");
         }
         String customerId = customerInfo.getGuid();
@@ -546,12 +549,18 @@ public class OrderInfoServiceImpl implements OrderInfoService {
         List<GoodsOrderDetail> dataList = new ArrayList<>();
         for (CreateOrderDetailFrom good : goods) {
             String goodsId = good.getGoodsId();
+
+
             //购买的碳汇量
             BigDecimal carbonVal = good.getCarbonVal();
-            GoodsInfo goodsInfo = goodsInfoMapper.selectByPrimaryKey(goodsId);
-            String goodsInfoGuid = goodsInfo.getGuid();
+            //获取销售信息
+            GoodsSaleInfoForm goodsInfo = orderSaleInfoService.getGoodsSaleInfoByGoodsId(goodsId);
+            if (StringUtils.isEmpty(goodsInfo)) {
+                throw new RuntimeException("该商品不存在");
+            }
+            String goodsInfoGuid = goodsInfo.getFkGoodsGuid();
             //还剩碳汇量
-            BigDecimal carbonValRe = goodsInfo.getCarbonVal();
+            BigDecimal carbonValRe = goodsInfo.getUnsaledCarbonSkin();
             if (StringUtils.isEmpty(carbonValRe)) {
                 throw new RuntimeException("碳汇量不够了");
             }
@@ -559,7 +568,7 @@ public class OrderInfoServiceImpl implements OrderInfoService {
                 throw new RuntimeException("购买的碳汇量大于剩余的碳汇量");
             }
             //商品单价
-            BigDecimal price = goodsInfo.getPrice();
+            BigDecimal price = goodsInfo.getSalePrice();
             //单个碳汇总价
             BigDecimal sum = carbonVal.multiply(price);
 
@@ -571,8 +580,18 @@ public class OrderInfoServiceImpl implements OrderInfoService {
 //            goodsInfo.setCarbonVal(reCarbonVal);
 //            goodsInfoMapper.updateByPrimaryKeySelective(goodsInfo);
 
-            updateGoods(carbonVal,goodsInfoGuid);
-
+            RLock lock = redissonClient.getLock(goodsId);
+            try {
+                //加锁 操作很类似Java的ReentrantLock机制
+                lock.lock();
+                updateGoods(carbonVal, goodsInfoGuid);
+            } catch (Exception e) {
+                System.out.println(e.getMessage());
+                throw new RuntimeException("请重新抢购!");
+            } finally {
+                //解锁
+                lock.unlock();
+            }
             //获取小订单
             addGoodsOrderDetail(customerId, orderId, dataList, good, goodsInfo, sum);
         }
@@ -584,7 +603,7 @@ public class OrderInfoServiceImpl implements OrderInfoService {
         //新增小定单
         goodsOrderDetailMapper.batchSaveOrderDetailList(dataList);
 
-        String message = "order-" +orderId;
+        String message = "order-" + orderId;
         //延时消息队列
         messageService.send(MQConstant.HELLO_QUEUE_NAME, message, 60000);
         return goodsOrderInfo;
@@ -610,22 +629,25 @@ public class OrderInfoServiceImpl implements OrderInfoService {
         goodsOrderInfo.setOrderAmount(sumTotal);
         //碳汇总数量
         goodsOrderInfo.setOrderCarbonAmount(carbonTotal);
+        //设置为线上订单
+        goodsOrderInfo.setOrderType(0);
     }
 
-    private void addGoodsOrderDetail(String customerId, String orderId, List<GoodsOrderDetail> dataList, CreateOrderDetailFrom good, GoodsInfo goodsInfo, BigDecimal sum) {
+    private void addGoodsOrderDetail(String customerId, String orderId, List<GoodsOrderDetail> dataList, CreateOrderDetailFrom good, GoodsSaleInfoForm goodsInfo, BigDecimal sum) {
         GoodsOrderDetail goodsOrderDetail = new GoodsOrderDetail();
         goodsOrderDetail.setGuid(GetUUID.getUUID());
         goodsOrderDetail.setCreateUser(customerId);
         goodsOrderDetail.setCreateTime(new Date());
-        goodsOrderDetail.setGoodsPrice(goodsInfo.getPrice());
+        goodsOrderDetail.setGoodsPrice(goodsInfo.getSalePrice());
         //设置单个销售总价
         goodsOrderDetail.setAmount(sum);
         //设置谈汇量
         goodsOrderDetail.setSaleNum(good.getCarbonVal());
         //设置商品id
-        goodsOrderDetail.setFkGoodsGuid(goodsInfo.getGuid());
+        goodsOrderDetail.setFkGoodsGuid(goodsInfo.getFkGoodsGuid());
         //设置商品名称
-        goodsOrderDetail.setGoodsName(goodsInfo.getGoodsName());
+        GoodsInfo goods = goodsInfoMapper.selectByPrimaryKey(goodsInfo.getFkGoodsGuid());
+        goodsOrderDetail.setGoodsName(goods.getGoodsName());
         goodsOrderDetail.setFkOrderGuid(orderId);
         goodsOrderDetail.setState(1);
 
@@ -656,15 +678,16 @@ public class OrderInfoServiceImpl implements OrderInfoService {
         goodsPayOrder.setPayNo(orderNum);
         goodsPayOrderMapper.insertSelective(goodsPayOrder);
     }
+
     @Override
-    public void payOrder(String orderId){
+    public void payOrder(String orderId) {
         GoodsOrderInfo goodsOrderInfo = goodsOrderInfoMapper.selectByPrimaryKey(orderId);
         Integer orderStatus = goodsOrderInfo.getOrderStatus();
-        if(orderStatus.intValue() !=1){
+        if (orderStatus.intValue() != 1) {
             throw new RuntimeException("该订单已支付!");
         }
         Integer state = goodsOrderInfo.getState();
-        if(state.intValue() == 0){
+        if (state.intValue() == 0) {
             throw new RuntimeException("该订单为无效订单!");
         }
         goodsOrderInfo.setOrderStatus(2);

+ 26 - 0
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/task/AutoTask.java

@@ -0,0 +1,26 @@
+package com.hcloud.microserver.h5.task;
+
+import com.hcloud.microserver.commoncore.util.reflect.DateUtils;
+import com.hcloud.microserver.h5.service.CustomerCarbonValService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+
+@EnableScheduling
+@Component
+@Slf4j
+public class AutoTask {
+
+    @Autowired
+    private CustomerCarbonValService customerCarbonValService;
+    //每年的1月1号0时1分0秒执行
+    @Scheduled(cron="0 1 0 1 1 ?")
+    public void process(){
+        log.info("执行碳汇量贡献自动生成任务 : "+ DateUtils.getDateInfo());
+        customerCarbonValService.contribution();
+    }
+}

+ 52 - 0
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/util/CurrUserUtil.java

@@ -0,0 +1,52 @@
+package com.hcloud.microserver.h5.util;
+
+import com.hcloud.microserver.commoncore.enums.ResultEnum;
+import com.hcloud.microserver.commoncore.exception.GlobalException;
+import com.hcloud.microserver.commoncore.util.string.StringUtils;
+import com.hcloud.microserver.h5.bo.CustomerDetails;
+import com.hcloud.microserver.h5.facade.carbon.forms.CustomerInfoForm;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContext;
+import org.springframework.security.core.context.SecurityContextHolder;
+
+/**
+ * @className:
+ * @description: 当前登录用户
+ * @author: lym
+ * @date: 2020/11/27
+ */
+public class CurrUserUtil {
+
+    public static CustomerInfoForm getCurrentMember() {
+        SecurityContext ctx = SecurityContextHolder.getContext();
+        Authentication auth = ctx.getAuthentication();
+        Object principal = auth.getPrincipal();
+        if (principal instanceof CustomerDetails) {
+            CustomerDetails memberDetails = (CustomerDetails) principal;
+            return memberDetails.getCustomerInfo();
+        }
+        return null;
+    }
+
+    public static CustomerInfoForm getCurrentCustomerInfo(){
+        CustomerInfoForm customerInfo = getCurrentMember();
+        if (customerInfo == null) {
+            throw new GlobalException(ResultEnum.TOKEN_EXPIRED);
+        }
+        return customerInfo;
+    }
+
+    /**
+     * 获取登录用户id
+     * lym
+     * @return
+     */
+    public static String getCustomerId(){
+        CustomerInfoForm customerInfo = getCurrentCustomerInfo();
+        String customerId = customerInfo.getGuid();
+        if (StringUtils.isEmpty(customerId)) {
+            throw new GlobalException(ResultEnum.TOKEN_EXPIRED);
+        }
+        return customerId;
+    }
+}

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

@@ -1,115 +1,119 @@
 <?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.h5.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>
+<mapper namespace="com.hcloud.microserver.h5.dao.CustomerCarbonValMapper">
+    <resultMap id="BaseResultMap" type="com.hcloud.microserver.h5.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>
-          </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>
+        </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>
-          </trim>
-        </if>
-      </foreach>
-    </where>
-  </sql>
-  <sql id="Base_Column_List" >
+        </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.h5.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" >
+    <select id="selectByExample" resultMap="BaseResultMap"
+            parameterType="com.hcloud.microserver.h5.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.h5.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.h5.facade.carbon.entity.CustomerCarbonVal" >
+    <delete id="deleteByExample"
+            parameterType="com.hcloud.microserver.h5.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.h5.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, 
@@ -121,219 +125,221 @@
       #{createUser,jdbcType=CHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateUser,jdbcType=CHAR}, 
       #{updateTime,jdbcType=TIMESTAMP})
   </insert>
-  <insert id="insertSelective" parameterType="com.hcloud.microserver.h5.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.h5.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" >
+    <insert id="insertSelective" parameterType="com.hcloud.microserver.h5.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.h5.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},
-      </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.h5.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.h5.facade.carbon.entity.CustomerCarbonVal" >
+        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.h5.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.h5.facade.carbon.entity.CustomerCarbonVal">
     update t_customer_carbon_val
     set t_customer_id = #{tCustomerId,jdbcType=CHAR},
       t_customer_name = #{tCustomerName,jdbcType=VARCHAR},
@@ -351,28 +357,163 @@
     where guid = #{guid,jdbcType=CHAR}
   </update>
 
-  <select id="getCustomerCarbonValRankList" parameterType="com.hcloud.microserver.h5.facade.carbon.forms.CustomerCarbonValRankForm"
-      resultType="com.hcloud.microserver.h5.facade.carbon.forms.CustomerCarbonValRankForm">
-      SELECT obj.* from (SELECT @rownum := @rownum + 1 AS rank,tmp.t_customer_id AS customerId,tmp.carbonVal
+    <!-- 查询客户购碳量排行榜 lym -->
+    <select id="getCustomerCarbonValRankList"
+            parameterType="com.hcloud.microserver.h5.facade.carbon.forms.CustomerCarbonValRankForm"
+            resultType="com.hcloud.microserver.h5.facade.carbon.forms.CustomerCarbonValRankForm">
+        SELECT obj.* from (SELECT @rownum := @rownum + 1 AS rank,tmp.t_customer_id AS customerId,tmp.carbonVal
         ,IFNULL(c.customer_name,c.nick_name) AS customerName,c.head_image AS headImage
         FROM (SELECT @rownum := 0) r,(SELECT a.t_customer_id,SUM(a.carbon_val) AS carbonVal
         FROM t_customer_carbon_val a
         INNER JOIN t_customer_info b ON b.guid = a.t_customer_id
-        WHERE a.year_time BETWEEN YEAR(DATE_SUB(NOW(),INTERVAL 3 YEAR)) AND YEAR(NOW())
-        AND a.type = 1
+        WHERE a.`status` = 1
+        <!-- AND a.year_time BETWEEN YEAR(DATE_SUB(NOW(),INTERVAL 3 YEAR)) AND YEAR(NOW()) -->
         <if test="type != null and type == 1">
-          AND b.customer_type = 1
+            AND b.customer_type = 1
         </if>
         <if test="type != null and type == 2">
-          AND b.customer_type != 1
+            AND b.customer_type != 1
         </if>
         GROUP BY t_customer_id
         ) tmp
         LEFT JOIN t_customer_info c ON tmp.t_customer_id = c.guid
         ORDER BY tmp.carbonVal DESC
-      ) obj WHERE 1 = 1
+        ) obj WHERE 1 = 1
         <if test="customerId != null and isCurrCustomerRank != null and isCurrCustomerRank == true">
-          AND obj.CustomerId = #{customerId}
+            AND obj.CustomerId = #{customerId}
         </if>
-  </select>
+    </select>
+    <select id="selectCarbonAmountByCustomerId" resultType="java.math.BigDecimal">
+        SELECT
+            SUM(a.carbon_val)
+        FROM
+            t_customer_carbon_val a
+        WHERE
+            1=1
+            AND a.`status` = 1
+            AND a.t_customer_id = #{guid}
+    </select>
+    <select id="totalcarbonVal" resultType="com.hcloud.microserver.h5.bo.ContributionBO">
+     SELECT
+        a.t_customer_id AS tCustomerId,
+        a.t_customer_name AS tCustomerName,
+        IFNULL(SUM(a.carbon_val), 0) AS carbonAmount,
+        a.year_time AS yearTime
+      FROM
+      t_customer_carbon_val a
+      WHERE
+      a.year_time <![CDATA[=]]> #{year}
+      AND a.`status` = 1
+      AND a.`type` != 5
+      GROUP BY
+      a.t_customer_id
+    </select>
+    <select id="subcarbonVal" resultType="com.hcloud.microserver.h5.bo.ContributionBO">
+     SELECT
+        a.t_customer_id AS tCustomerId,
+        a.t_customer_name AS tCustomerName,
+        IFNULL(SUM(a.carbon_val), 0) AS carbonAmount,
+        a.year_time AS yearTime
+      FROM
+      t_customer_carbon_val a
+      WHERE
+      a.year_time <![CDATA[=]]> #{year}
+      AND a.`status` = 0
+      AND a.`type` != 5
+      GROUP BY
+      a.t_customer_id
+    </select>
+
+    <select id="contribution" resultType="com.hcloud.microserver.h5.bo.ContributionBO">
+     SELECT
+        a.t_customer_id AS tCustomerId,
+        a.t_customer_name AS tCustomerName,
+        IFNULL(SUM(a.carbon_val), 0) AS carbonAmount,
+        a.year_time AS yearTime
+      FROM
+      t_customer_carbon_val a
+      WHERE
+      a.year_time <![CDATA[=]]> #{year}
+      AND a.`status` = 0
+      AND a.`type` = 5
+      AND a.t_customer_id = #{customerid}
+      GROUP BY
+      a.t_customer_id
+    </select>
+
+
+    <insert id="insertSelectiveList">
+        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
+        <foreach collection="list" item="item" index="index" separator=",">
+            (
+            #{item.guid},
+            #{item.tCustomerId},
+            #{item.tCustomerName},
+            #{item.carbonVal},
+            #{item.status},
+            #{item.type},
+            #{item.tbGuid},
+            #{item.tbName},
+            #{item.remarks},
+            #{item.yearTime},
+            #{item.createUser},
+            #{item.createTime},
+            #{item.updateUser},
+            #{item.updateTime}
+            )
+        </foreach>
+
+    </insert>
+
+
+    <select id="myCarbonVal" resultType="com.hcloud.microserver.h5.bo.MyCarbonValBO">
+        SELECT
+        a.type,
+        CASE a.type
+        WHEN 1 THEN
+        '购买碳汇'
+        WHEN 2 THEN
+        '企业碳中和'
+        WHEN 3 THEN
+        '大型活动碳中和'
+        WHEN 4 THEN
+        '碳履约'
+        WHEN 5 THEN
+        '为重庆市碳排放量做贡献'
+        ELSE
+        '购买碳汇'
+        END 'status',
+        SUM(a.carbon_val) AS totalCarbonVal
+        FROM
+        t_customer_carbon_val a
+        WHERE
+        1=1
+        <choose>
+            <when test="year != null">
+                AND a.year_time = #{year}
+            </when>
+            <otherwise>
+                AND a.year_time = NOW()
+            </otherwise>
+        </choose>
+        AND a.t_customer_id = #{guid}
+        GROUP BY
+        a.type
+    </select>
 </mapper>

+ 4 - 1
carbon-h5/carbon-h5-service/src/main/resources/com/hcloud/microserver/h5/dao/GoodsCredentialInfoMapper.xml

@@ -52,7 +52,9 @@
         bb.customer_name AS customerName,
         bb.nick_name AS nickName,
         cc.company_name AS companyName,
-        dd.order_amount AS OrderAmount
+        dd.order_amount AS OrderAmount,
+        aa.farmer_names AS farmerName,
+        YEAR(aa.buy_date) AS year
     FROM
         t_goods_credential_info aa
     LEFT JOIN t_goods_order_info dd ON aa.fk_order_id = dd.guid
@@ -69,6 +71,7 @@
       <include refid="Base_Column_List" />
       from t_goods_credential_info
       where fk_customer_id = #{customerId}
+      ORDER BY create_time DESC
   </select>
   <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
     delete from t_goods_credential_info

+ 1 - 1
carbon-h5/carbon-h5-service/src/main/resources/com/hcloud/microserver/h5/dao/GoodsManageMapper.xml

@@ -46,7 +46,7 @@
         aa.goods_name AS goodsName,
         aa.goods_images AS goodsImages,
         aa.goods_type AS goodsType,
-        aa.price,
+        bb.sale_price AS price,
         aa.goods_use AS goodsUse,
         bb.sale_unit AS saleUnit,
         bb.saled_carbon_skin AS saledCarbonSkin,

+ 18 - 1
carbon-h5/carbon-h5-service/src/main/resources/com/hcloud/microserver/h5/dao/GoodsOrderInfoMapper.xml

@@ -194,6 +194,9 @@
       <if test="payNo != null">
         pay_no,
       </if>
+      <if test="orderType != null">
+        order_type,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="guid != null">
@@ -238,6 +241,9 @@
       <if test="payNo != null">
         #{payNo,jdbcType=VARCHAR},
       </if>
+      <if test="orderType != null">
+        #{orderType,jdbcType=VARCHAR},
+      </if>
     </trim>
   </insert>
   <update id="updateByPrimaryKeySelective" parameterType="GoodsOrderInfo">
@@ -317,11 +323,22 @@
         aa.order_status AS orderStatus,
         aa.order_amount AS orderAmount,
         aa.order_carbon_amount AS orderCarbonAmount,
-        aa.pay_no AS payNo
+        aa.pay_no AS payNo,
+        aa.state AS state
         FROM
         t_goods_order_info aa
         WHERE
         1=1
         AND aa.guid = #{guid}
     </select>
+    <select id="payChannel" resultType="java.lang.Integer">
+        SELECT
+            a.pay_channel
+        FROM
+            t_goods_pay_order a
+        WHERE
+            a.pay_status = '2'
+        AND a.fk_order_id = #{guid}
+        LIMIT 1
+    </select>
 </mapper>

+ 62 - 33
common-core/src/main/java/com/hcloud/microserver/commoncore/util/TracedCodeUtils.java

@@ -3,8 +3,8 @@ package com.hcloud.microserver.commoncore.util;
 import com.hcloud.microserver.commoncore.util.string.StrUtil;
 import lombok.extern.slf4j.Slf4j;
 
-import java.util.Arrays;
-import java.util.List;
+import java.util.*;
+import java.util.concurrent.TimeUnit;
 
 /**
  * @author JYJ
@@ -12,6 +12,57 @@ import java.util.List;
 @Slf4j
 public class TracedCodeUtils {
 
+    public static void main(String[] args) throws InterruptedException {
+        Map<String, Long> map = new HashMap<>();
+        long starttime = new Date().getTime();
+        System.err.println();
+        for (int i = 0; i < 10000000; i++) {
+            String commonRandomCode = generateShortUuid();
+            Long count = map.get(commonRandomCode);
+            if (null != count) {
+                count = count + 1L;
+                map.put(commonRandomCode, count);
+            } else {
+                map.put(commonRandomCode, 1L);
+            }
+            System.err.println(commonRandomCode);
+
+        }
+
+        for (String s : map.keySet()) {
+            Long count = map.get(s);
+            if (count > 1) {
+                System.err.println(s + "---" + count);
+            }else {
+                //System.err.println(s + "---" + count);
+            }
+        }
+        long endtime = new Date().getTime();
+        long diff = endtime - starttime;
+        long time = diff / 1000;
+        System.err.println(time+":秒");
+    }
+
+    public static String[] chars = new String[]{"a", "b", "c", "d", "e", "f",
+            "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s",
+            "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5",
+            "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I",
+            "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V",
+            "W", "X", "Y", "Z"};
+
+
+    public static String generateShortUuid() {
+        StringBuffer shortBuffer = new StringBuffer();
+        String uuid = UUID.randomUUID().toString().replace("-", "");
+        for (int i = 0; i < 8; i++) {
+            String str = uuid.substring(i * 4, i * 4 + 4);
+            int x = Integer.parseInt(str, 16);
+            shortBuffer.append(chars[x % 0x3E]);
+        }
+        return shortBuffer.toString();
+
+    }
+
     private static final Integer[] ASCII_NUM = {65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
             78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90};
     private static final String[] ASCII_WORD = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
@@ -58,49 +109,27 @@ public class TracedCodeUtils {
 
     /**
      * 生成不重复的用户账号
+     *
      * @return
      */
-    public static String getCommonRandomCode(){
+    public static String getCommonRandomCode() {
         long nowDate = System.currentTimeMillis();
         StringBuffer ssb = new StringBuffer();
-        String sid = Integer.toHexString((int)nowDate);
+        String sid = Integer.toHexString((int) nowDate);
         List<String> arrayList = Arrays.asList(sid.split(""));
-        for(int i = 0; i < arrayList.size(); i++){
+        for (int i = 0; i < arrayList.size(); i++) {
             String tmp = arrayList.get(i);
-            if(!StrUtil.isNumeric(tmp)){
-                for (int j = 0; j <ASCII_WORD.length ; j++) {
+            if (!StrUtil.isNumeric(tmp)) {
+                for (int j = 0; j < ASCII_WORD.length; j++) {
                     String inner = ASCII_WORD[j];
-                    if(tmp.equalsIgnoreCase(inner)){
-                        ssb.append(ASCII_NUM[j]/10);
+                    if (tmp.equalsIgnoreCase(inner)) {
+                        ssb.append(ASCII_NUM[j] / 10);
                     }
                 }
-            }else{
+            } else {
                 ssb.append(tmp);
             }
         }
         return ssb.toString();
     }
-
-//    public static void main(String[] args) {
-//        long nowDate = System.currentTimeMillis();
-//        StringBuffer ssb = new StringBuffer();
-//        String sid = Integer.toHexString((int)nowDate);
-//        List<String> arrayList = Arrays.asList(sid.split(""));
-//        for(int i = 0; i < arrayList.size(); i++){
-//            String tmp = arrayList.get(i);
-//            if(!StrUtil.isNumeric(tmp)){
-//                for (int j = 0; j <ASCII_WORD.length ; j++) {
-//                    String inner = ASCII_WORD[j];
-//                    if(tmp.equalsIgnoreCase(inner)){
-//                        ssb.append(ASCII_NUM[j]/10);
-//                    }
-//                }
-//            }else{
-//                ssb.append(tmp);
-//            }
-//
-//        }
-//        System.out.println(ssb.toString());
-//
-//    }
 }

+ 12 - 0
common-core/src/main/java/com/hcloud/microserver/commoncore/util/reflect/DateUtils.java

@@ -50,6 +50,18 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
         return dateTimeNow(YYYY_MM_DD);
     }
 
+    /**
+     * 获取当前日期, 默认格式为yyyy-MM-dd
+     *
+     * @return String
+     */
+    public static String getDateInfo()
+    {
+        return dateTimeNow(YYYY_MM_DD_HH_MM_SS);
+    }
+
+
+
     public static final String getTime()
     {
         return dateTimeNow(YYYY_MM_DD_HH_MM_SS);

+ 4 - 1
sql/表结构变化语句/更新sql.sql

@@ -5,6 +5,9 @@ ALTER TABLE `t_goods_info` MODIFY COLUMN  `is_sale` int(11) DEFAULT NULL COMMENT
 #修改订单表 state 字段备注
 ALTER TABLE `t_goods_order_info` MODIFY COLUMN `state` int(11) DEFAULT NULL COMMENT '记录状态 0无效 1有效';
 
+#修改证书表 state 字段备注
+ALTER TABLE `t_goods_credential_info` MODIFY COLUMN `state` int(11) DEFAULT NULL COMMENT '类型 1 购买碳汇';
+
 #新增企业类型表 lym
 CREATE TABLE `t_customer_company_type` (
   `guid` char(32) CHARACTER SET utf8mb4 NOT NULL,
@@ -42,7 +45,7 @@ CREATE TABLE `t_customer_carbon_val` (
   `t_customer_name` varchar(50) DEFAULT NULL COMMENT '用户名称',
   `carbon_val` decimal(10,2) DEFAULT NULL COMMENT '购买碳汇量',
   `status` int(1) DEFAULT NULL COMMENT '状态 1 新增 0 减去',
-  `type` int(1) DEFAULT NULL COMMENT '类型 1购买碳汇 2企业碳中和 3大型活动碳中和 4碳履约',
+  `type` int(1) DEFAULT NULL COMMENT '类型 1购买碳汇 2企业碳中和 3大型活动碳中和 4碳履约 5为重庆市碳排放量做贡献',
   `tb_guid` char(32) DEFAULT NULL COMMENT '来源表id',
   `tb_name` char(20) DEFAULT NULL COMMENT '表名称',
   `remarks` char(32) DEFAULT NULL COMMENT '来源明细',