diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxVtwoPrizeDrawActivityController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxVtwoPrizeDrawActivityController.java index ea4788d1e..7da141f62 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxVtwoPrizeDrawActivityController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxVtwoPrizeDrawActivityController.java @@ -301,6 +301,7 @@ public class WxVtwoPrizeDrawActivityController extends BaseController { // return new ResultData(Result.ERROR,"签名为空"); // } activityGrant.setCreateBy(getUserId()); + activityGrant.setCreateByName(getUser().getName()); try{ wxVtwoPrizeDrawActivityService.grantAward(prizeDrawActivity, activityGrant); return new ResultData(); diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxVtwoActivityGrant.java b/mallinkService/src/main/java/com/iformall/domain/po/WxVtwoActivityGrant.java index 4d5cd246c..44c93da53 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxVtwoActivityGrant.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxVtwoActivityGrant.java @@ -140,6 +140,8 @@ public class WxVtwoActivityGrant extends TenantEntity { */ @TableField(value = "create_by") private Long createBy; + @TableField(exist = false) + private String createByName; /** * 创建时间 diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxVtwoActivityGrantExport.java b/mallinkService/src/main/java/com/iformall/domain/po/WxVtwoActivityGrantExport.java index ff86eccab..b1398a71a 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxVtwoActivityGrantExport.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxVtwoActivityGrantExport.java @@ -103,31 +103,31 @@ public class WxVtwoActivityGrantExport extends TenantEntity { /** * 审批状态 */ - @TableField(value = "order_audit_status") + @TableField(exist = false) private Integer orderAuditStatus; /** * 审核人 */ - @TableField(value = "order_audit_by") + @TableField(exist = false) private Long orderAuditBy; /** * */ - @TableField(value = "order_audit_name") + @TableField(exist = false) private String orderAuditName; /** * 审批意见 */ - @TableField(value = "order_audit_remark") + @TableField(exist = false) private String orderAuditRemark; /** * 审核时间 */ - @TableField(value = "order_audit_time") + @TableField(exist = false) private Date orderAuditTime; /** diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxVtwoActivityGrantExportMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxVtwoActivityGrantExportMapper.java index f439564c0..d6187278d 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxVtwoActivityGrantExportMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxVtwoActivityGrantExportMapper.java @@ -3,6 +3,9 @@ package com.iformall.mapper; import com.iformall.common.CommonMapper; import com.iformall.domain.po.WxVtwoActivityGrantExport; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * @author xiaohu @@ -12,6 +15,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; */ public interface WxVtwoActivityGrantExportMapper extends CommonMapper { + void insertList(@Param("grantExportList")List grantExportList); } diff --git a/mallinkService/src/main/java/com/iformall/service/WxVtwoActivityGrantExportService.java b/mallinkService/src/main/java/com/iformall/service/WxVtwoActivityGrantExportService.java index 79c2bb3a1..9d091c61e 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxVtwoActivityGrantExportService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxVtwoActivityGrantExportService.java @@ -1,7 +1,11 @@ package com.iformall.service; +import com.iformall.domain.po.WxVtwoActivityGrant; import com.iformall.domain.po.WxVtwoActivityGrantExport; import com.baomidou.mybatisplus.extension.service.IService; +import com.iformall.domain.po.WxVtwoActivityGrantSettlement; + +import java.util.List; /** * @author xiaohu @@ -10,4 +14,5 @@ import com.baomidou.mybatisplus.extension.service.IService; */ public interface WxVtwoActivityGrantExportService extends IService { + void saveGrantExport(WxVtwoActivityGrant activityGrant, List settlementList); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxVtwoActivityGrantExportServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxVtwoActivityGrantExportServiceImpl.java index 68e87cb01..a313ce407 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxVtwoActivityGrantExportServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxVtwoActivityGrantExportServiceImpl.java @@ -1,11 +1,25 @@ package com.iformall.service.impl; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.iformall.common.IdWorker; +import com.iformall.domain.po.WxVtwoActivityGrant; import com.iformall.domain.po.WxVtwoActivityGrantExport; +import com.iformall.domain.po.WxVtwoActivityGrantSettlement; +import com.iformall.domain.po.WxVtwoActivityOrder; import com.iformall.service.WxVtwoActivityGrantExportService; import com.iformall.mapper.WxVtwoActivityGrantExportMapper; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; + /** * @author xiaohu * @description 针对表【wx_vtwo_activity_grant_export(线下活动发放奖励导出)】的数据库操作Service实现 @@ -15,6 +29,84 @@ import org.springframework.stereotype.Service; public class WxVtwoActivityGrantExportServiceImpl extends ServiceImpl implements WxVtwoActivityGrantExportService{ + @Autowired + private WxVtwoActivityGrantExportMapper wxVtwoActivityGrantExportMapper; + + @Override + public void saveGrantExport(WxVtwoActivityGrant activityGrant, List settlementList) { + + Map> orderSettlementMap = settlementList.stream().collect(Collectors.groupingBy(WxVtwoActivityGrantSettlement::getOrderId)); + Map orderMap = activityGrant.getOrderList().stream().collect(Collectors.toMap(WxVtwoActivityOrder::getId, Function.identity())); + List grantExportList = new ArrayList<>(); + final IdWorker idWorker = IdWorker.get(); + orderSettlementMap.keySet().forEach(orderId -> { + List orderSettlementList = orderSettlementMap.get(orderId); + WxVtwoActivityOrder order = orderMap.get(orderId); + + WxVtwoActivityGrantExport grantExport = getGrantExport(order,orderSettlementList); + grantExport.setId(idWorker.nextId()); + grantExport.setActivityId(activityGrant.getActivityId()); + grantExport.setGrantId(activityGrant.getId()); + grantExport.setGrantUserName(activityGrant.getRealName()); + grantExport.setGrantUserCard(activityGrant.getRealCard()); + grantExport.setGrantBy(activityGrant.getCreateBy()); + grantExport.setGrantByName(activityGrant.getCreateByName()); + grantExport.setGrantTime(activityGrant.getCreateDate()); + grantExport.setGrantRemark(activityGrant.getRemark()); + grantExport.setSignImg(activityGrant.getSignImg()); + + + }); + wxVtwoActivityGrantExportMapper.insertList(grantExportList); + } + + private WxVtwoActivityGrantExport getGrantExport(WxVtwoActivityOrder order,List orderSettlementList){ + WxVtwoActivityGrantExport grantExport = new WxVtwoActivityGrantExport(); + grantExport.updateTenantInfo(order); + grantExport.setOrderId(order.getId()); + grantExport.setOrderNo(order.getOrderNo()); + grantExport.setOrderAmount(order.getOrderMoney()); + grantExport.setMerchantId(order.getMerchantId()); + grantExport.setMerchantName(order.getMerchantName()); + grantExport.setMerchantShopNum(order.getShopNumber()); + grantExport.setBusinessId(order.getBusinessId()); + grantExport.setBusinessName(order.getBusinessName()); + grantExport.setLotteryNum(order.getLotteryNumStr()); + grantExport.setLotteryNum(order.getLotteryNum()); + grantExport.setAnniversaryLotteryNum(order.getAnniversaryLotteryNum()); + grantExport.setOrderCreateTime(order.getCreateDate()); + grantExport.setVipNum(order.getVipNum()); + grantExport.setCusName(order.getCusName()); + grantExport.setCusPhone(order.getCusPhone()); + grantExport.setCusAddress(order.getCusAddress()); + grantExport.setLegionId(order.getLegionId()); + grantExport.setLegionName(order.getLegionName()); + grantExport.setUnionId(order.getUnionId()); + grantExport.setUnionName(order.getUnionName()); + + grantExport.setGrantDetail(JSONObject.toJSONString(orderSettlementList)); + BigDecimal grantPrice = BigDecimal.ZERO; + BigDecimal mallSharePrice = BigDecimal.ZERO; + BigDecimal merchantSharePrice = BigDecimal.ZERO; + BigDecimal taxAmount = BigDecimal.ZERO; + for (WxVtwoActivityGrantSettlement grantSettlement:orderSettlementList){ + grantPrice = grantPrice.add(grantSettlement.getOrderGrantPrice()); + mallSharePrice = mallSharePrice.add(grantSettlement.getOrderMallSharePrice()); + merchantSharePrice = merchantSharePrice.add(grantSettlement.getOrderMerchantSharePrice()); + if(grantSettlement.getTaxAmount() != null ){ + taxAmount = taxAmount.add(grantSettlement.getTaxAmount()); + } + } + grantExport.setGrantPrice(grantPrice); + grantExport.setMallSharePrice(mallSharePrice); + grantExport.setMerchantSharePrice(merchantSharePrice); + grantExport.setMallShareRate(mallSharePrice.divide(grantPrice,4, RoundingMode.HALF_UP) + .multiply(new BigDecimal(100))); + grantExport.setMerchantShareRate(merchantSharePrice.divide(grantPrice,4, RoundingMode.HALF_UP) + .multiply(new BigDecimal(100))); + grantExport.setTaxAmount(taxAmount); + return grantExport; + } } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxVtwoActivityGrantSettlementServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxVtwoActivityGrantSettlementServiceImpl.java index 82d2c14fd..fa190df6c 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxVtwoActivityGrantSettlementServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxVtwoActivityGrantSettlementServiceImpl.java @@ -5,6 +5,8 @@ import com.iformall.common.IdWorker; import com.iformall.domain.po.*; import com.iformall.enums.EnumOfflineActivityAwardsModeType; import com.iformall.enums.EnumYesOrNo; +import com.iformall.mapper.WxVtwoActivityGrantMapper; +import com.iformall.service.WxVtwoActivityGrantExportService; import com.iformall.service.WxVtwoActivityGrantSettlementService; import com.iformall.mapper.WxVtwoActivityGrantSettlementMapper; import org.springframework.beans.factory.annotation.Autowired; @@ -31,6 +33,9 @@ public class WxVtwoActivityGrantSettlementServiceImpl extends ServiceImpl amountOrderList = activityGrant.getOrderList().stream().filter(o -> EnumYesOrNo.YES.getCode().equals(o.getIsAmount())) @@ -70,6 +75,8 @@ public class WxVtwoActivityGrantSettlementServiceImpl extends ServiceImpl orderList){ diff --git a/mallinkService/src/main/resources/mapper/WxVtwoActivityGrantExportMapper.xml b/mallinkService/src/main/resources/mapper/WxVtwoActivityGrantExportMapper.xml index 21030bdd9..acb7d9347 100644 --- a/mallinkService/src/main/resources/mapper/WxVtwoActivityGrantExportMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxVtwoActivityGrantExportMapper.xml @@ -21,11 +21,6 @@ - - - - - @@ -59,8 +54,7 @@ order_amount,merchant_id,merchant_name, merchant_shop_num,business_id,business_name, lottery_num,lottery_count,anniversary_lottery_num, - order_create_time,order_audit_status,order_audit_by, - order_audit_name,order_audit_remark,order_audit_time, + order_create_time, vip_num,cus_name,cus_phone, cus_card,cus_address,legion_id, legion_name,union_id,union_name, @@ -110,4 +104,39 @@ select from wx_vtwo_activity_grant_export where id = #{id} and tenant_id=#{tenantId} + + + insert into wx_vtwo_activity_grant_export + (id, + activity_id,order_id,order_no, + order_amount,merchant_id,merchant_name, + merchant_shop_num,business_id,business_name, + lottery_num,lottery_count,anniversary_lottery_num, + order_create_time, + vip_num,cus_name,cus_phone, + cus_card,cus_address,legion_id, + legion_name,union_id,union_name, + grant_id,grant_user_name,grant_user_card, + grant_by,grant_by_name,grant_time,grant_remark, + sign_img,grant_detail,grant_price, + mall_share_price,merchant_share_price,mall_share_rate, + merchant_share_rate,tax_amount) + values + + (#{item.id,jdbcType=BIGINT}, + #{item.activityId,jdbcType=BIGINT},#{item.orderId,jdbcType=BIGINT},#{item.orderNo,jdbcType=VARCHAR}, + #{item.orderAmount,jdbcType=DECIMAL},#{item.merchantId,jdbcType=BIGINT},#{item.merchantName,jdbcType=VARCHAR}, + #{item.merchantShopNum,jdbcType=VARCHAR},#{item.businessId,jdbcType=INTEGER},#{item.businessName,jdbcType=VARCHAR}, + #{item.lotteryNum,jdbcType=VARCHAR},#{item.lotteryCount,jdbcType=INTEGER},#{item.anniversaryLotteryNum,jdbcType=VARCHAR}, + #{item.orderCreateTime,jdbcType=TIMESTAMP}, + #{item.vipNum,jdbcType=VARCHAR},#{item.cusName,jdbcType=VARCHAR},#{item.cusPhone,jdbcType=VARCHAR}, + #{item.cusCard,jdbcType=VARCHAR},#{item.cusAddress,jdbcType=VARCHAR},#{itemLegionId,jdbcType=BIGINT}, + #{item.legionName,jdbcType=VARCHAR},#{item.unionId,jdbcType=BIGINT},#{item.unionName,jdbcType=VARCHAR}, + #{item.grantId,jdbcType=BIGINT},#{item.grantUserName,jdbcType=VARCHAR},#{item.grantUserCard,jdbcType=VARCHAR}, + #{item.grantBy,jdbcType=BIGINT},#{item.grantByName,jdbcType=VARCHAR},#{item.grantTime,jdbcType=TIMESTAMP},#{item.grantRemark,jdbcType=VARCHAR}, + #{item.signImg,jdbcType=VARCHAR},#{item.grantDetail,jdbcType=VARCHAR},#{item.grantPrice,jdbcType=DECIMAL}, + #{item.mallSharePrice,jdbcType=DECIMAL},#{item.merchantSharePrice,jdbcType=DECIMAL},#{item.mallShareRate,jdbcType=DECIMAL}, + #{item.merchantShareRate,jdbcType=DECIMAL},#{item.taxAmount,jdbcType=DECIMAL}) + +