Просмотр исходного кода

fix card

release_toaliyun_real
lin 3 лет назад
Родитель
Сommit
14e1449175
6 измененных файлов: 192 добавлений и 77 удалений
  1. +2
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxMerchantSubsidy.java
  2. +2
    -0
      mallinkService/src/main/java/com/iformall/mapper/WxCardSpendMapper.java
  3. +4
    -0
      mallinkService/src/main/java/com/iformall/mapper/WxMerchantSubsidyMapper.java
  4. +142
    -55
      mallinkService/src/main/java/com/iformall/service/impl/WxCardSpendServiceImpl.java
  5. +19
    -21
      mallinkService/src/main/resources/mapper/WxCardSpendMapper.xml
  6. +23
    -1
      mallinkService/src/main/resources/mapper/WxMerchantSubsidyMapper.xml

+ 2
- 0
mallinkService/src/main/java/com/iformall/domain/po/WxMerchantSubsidy.java Просмотреть файл

@@ -40,6 +40,8 @@ public class WxMerchantSubsidy extends TenantEntity {

@io.swagger.annotations.ApiModelProperty(value="商户ID",name="merchantId")
private Long merchantId;
@TableField(exist = false)
private List<Long> merchantIdList;

@io.swagger.annotations.ApiModelProperty(value = "b端核销商场tenantId", name = "bTenantId")
private String bTenantId;


+ 2
- 0
mallinkService/src/main/java/com/iformall/mapper/WxCardSpendMapper.java Просмотреть файл

@@ -14,6 +14,8 @@ public interface WxCardSpendMapper extends CommonMapper<WxCardSpend, Long> {
int findCount(WxCardSpend wxCardSpend);

List<Map<String,Object>> getMerchantCount(WxCardSpend wxCardSpend);
List<Long> getMerchantIdList(WxCardSpend wxCardSpend);

List<Map<String,Object>> sumCardSpendVoForMerchant(WxCardSpendVo wxCardSpend);



+ 4
- 0
mallinkService/src/main/java/com/iformall/mapper/WxMerchantSubsidyMapper.java Просмотреть файл

@@ -23,4 +23,8 @@ public interface WxMerchantSubsidyMapper extends CommonMapper<WxMerchantSubsidy,
int deleteById(@Param("id")Long id,@Param("tenantId")String tenantId);
List<Map<String,Object>> sumByMerchantId(WxMerchantSubsidy wxMerchantSubsidy);
Map<String,Integer> sum(WxMerchantSubsidy wxMerchantSubsidy);
}

+ 142
- 55
mallinkService/src/main/java/com/iformall/service/impl/WxCardSpendServiceImpl.java Просмотреть файл

@@ -404,6 +404,74 @@ public class WxCardSpendServiceImpl implements WxCardSpendService {
return false;
}

private Map<Long,WxMerchant> getMerchantMap(List<Long> merchantIdList,TenantEntity tenantEntity) {
Map<Long,WxMerchant> merchantMap = new HashMap<Long,WxMerchant>();
if (merchantIdList.size() > 0 ){
WxMerchant mq = new WxMerchant();
mq.updateTenantInfo(tenantEntity);
mq.setIds(merchantIdList);
List<WxMerchant> merchantList = wxMerchantMapper.findList(mq);
if (null != merchantList && merchantList.size() > 0 ){
for (int i = 0 ;i < merchantList.size();i++){
WxMerchant m = merchantList.get(i);
merchantMap.put(m.getId(), m);
}
}
}
return merchantMap;
}
private Map<Long,WxCoupon> getCouponMap(List<Long> couponIdList,TenantEntity tenantEntity) {
Map<Long,WxCoupon> couponMap = new HashMap<Long,WxCoupon>();
if (couponIdList.size() > 0 ){
WxCoupon cq = new WxCoupon();
cq.updateTenantInfo(tenantEntity);
cq.setIds(couponIdList);
List<WxCoupon> couponList = wxCouponMapper.findList(cq);
if (null != couponList && couponList.size() > 0 ){
for (int i = 0 ;i < couponList.size();i++){
WxCoupon c = couponList.get(i);
couponMap.put(c.getId(),c);
}
}
}
return couponMap;
}
private Map<Long,WxMerchantSubsidy> getOrderSubsidyMap(List<Long> merchantSubsidyOrderIdList,TenantEntity tenantEntity){
Map<Long,WxMerchantSubsidy> orderSubsidyMap = new HashMap<Long,WxMerchantSubsidy>();
if (merchantSubsidyOrderIdList.size() > 0 ){
WxMerchantSubsidy msq = new WxMerchantSubsidy();
msq.updateTenantInfo(tenantEntity);
msq.setOrderIdList(merchantSubsidyOrderIdList);
List<WxMerchantSubsidy> msqList = wxMerchantSubsidyMapper.findList(msq);
if (null != msqList && msqList.size() > 0 ){
for (int i = 0 ;i < msqList.size();i++){
WxMerchantSubsidy c = msqList.get(i);
orderSubsidyMap.put(c.getOrderId(),c);
}
}
}
return orderSubsidyMap;
}
private Map<Long,WxCUserBasicInfo> getUserMap(List<Long> userIdList,TenantEntity tenantEntity) {
Map<Long,WxCUserBasicInfo> userMap = new HashMap<Long,WxCUserBasicInfo>();
if (userIdList.size() > 0 ){
WxCUserBasicInfo u = new WxCUserBasicInfo();
u.setFinalTenantId(tenantEntity.getFinalTenantId());
u.setIds(userIdList);
List<WxCUserBasicInfo> msqList = wxCUserBasicInfoMapper.findList(u);
if (null != msqList && msqList.size() > 0 ){
for (int i = 0 ;i < msqList.size();i++){
WxCUserBasicInfo c = msqList.get(i);
userMap.put(c.getId(),c);
}
}
}
return userMap;
}
private List<WxCardSpendVo> handleToCardSpendVoList(List<WxCardSpend> list,TenantEntity tenantEntity) {
if (null != list && list.size() > 0 ){
List<Long> merchantIdList = new ArrayList<Long>();
@@ -428,19 +496,8 @@ public class WxCardSpendServiceImpl implements WxCardSpendService {
}
Map<Long,WxMerchant> merchantMap = new HashMap<Long,WxMerchant>();
if (merchantIdList.size() > 0 ){
WxMerchant mq = new WxMerchant();
mq.updateTenantInfo(tenantEntity);
mq.setIds(merchantIdList);
List<WxMerchant> merchantList = wxMerchantMapper.findList(mq);
if (null != merchantList && merchantList.size() > 0 ){
for (int i = 0 ;i < merchantList.size();i++){
WxMerchant m = merchantList.get(i);
merchantMap.put(m.getId(), m);
}
}
}
Map<Long,WxMerchant> merchantMap = getMerchantMap(merchantIdList, tenantEntity);
Map<Long,Long> cardCouponIdMap = new HashMap<Long,Long>();
if (cardInfoIdList.size() > 0 ){
@@ -459,47 +516,11 @@ public class WxCardSpendServiceImpl implements WxCardSpendService {
}
}
Map<Long,WxCoupon> couponMap = new HashMap<Long,WxCoupon>();
if (couponIdList.size() > 0 ){
WxCoupon cq = new WxCoupon();
cq.updateTenantInfo(tenantEntity);
cq.setIds(couponIdList);
List<WxCoupon> couponList = wxCouponMapper.findList(cq);
if (null != couponList && couponList.size() > 0 ){
for (int i = 0 ;i < couponList.size();i++){
WxCoupon c = couponList.get(i);
couponMap.put(c.getId(),c);
}
}
}
Map<Long,WxCoupon> couponMap = getCouponMap(couponIdList, tenantEntity);
Map<Long,WxMerchantSubsidy> orderSubsidyMap = new HashMap<Long,WxMerchantSubsidy>();
if (merchantSubsidyOrderIdList.size() > 0 ){
WxMerchantSubsidy msq = new WxMerchantSubsidy();
msq.updateTenantInfo(tenantEntity);
msq.setOrderIdList(merchantSubsidyOrderIdList);
List<WxMerchantSubsidy> msqList = wxMerchantSubsidyMapper.findList(msq);
if (null != msqList && msqList.size() > 0 ){
for (int i = 0 ;i < msqList.size();i++){
WxMerchantSubsidy c = msqList.get(i);
orderSubsidyMap.put(c.getOrderId(),c);
}
}
}
Map<Long,WxMerchantSubsidy> orderSubsidyMap = getOrderSubsidyMap(merchantSubsidyOrderIdList, tenantEntity);
Map<Long,WxCUserBasicInfo> userMap = new HashMap<Long,WxCUserBasicInfo>();
if (userIdList.size() > 0 ){
WxCUserBasicInfo u = new WxCUserBasicInfo();
u.setFinalTenantId(tenantEntity.getFinalTenantId());
u.setIds(userIdList);
List<WxCUserBasicInfo> msqList = wxCUserBasicInfoMapper.findList(u);
if (null != msqList && msqList.size() > 0 ){
for (int i = 0 ;i < msqList.size();i++){
WxCUserBasicInfo c = msqList.get(i);
userMap.put(c.getId(),c);
}
}
}
Map<Long,WxCUserBasicInfo> userMap = getUserMap(userIdList, tenantEntity);
List<WxCardSpendVo> retList = new ArrayList<WxCardSpendVo>();
for (int i = 0 ; i < list.size(); i++ ){
@@ -543,7 +564,6 @@ public class WxCardSpendServiceImpl implements WxCardSpendService {
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
@@ -615,12 +635,79 @@ public class WxCardSpendServiceImpl implements WxCardSpendService {

@Override
public List<Map<String, Object>> sumCardSpendForMerchant(WxCardSpendVo record) {
return wxCardSpendMapper.sumCardSpendVoForMerchant(record);
handleQueryParam(record);
List<Long> merchantIdList = wxCardSpendMapper.getMerchantIdList(record);
Map<Long,WxMerchant> merchantMap = this.getMerchantMap(merchantIdList, record);
WxMerchantSubsidy sq = getWxMerchantSubsidyQuery(record,merchantIdList);
List<Map<String,Object>> merchantSubsidyMap = wxMerchantSubsidyMapper.sumByMerchantId(sq);
Map<Long,Map<String,Integer>> msmap = new HashMap<Long,Map<String,Integer>>();
if (null != merchantSubsidyMap && merchantSubsidyMap.size() > 0 ) {
for (int i = 0 ; i < merchantSubsidyMap.size(); i++) {
Map<String,Object> result = merchantSubsidyMap.get(i) ;
Map<String,Integer> submap = new HashMap<String,Integer>();
submap.put("sum_subsidy", (Integer)result.get("sum_subsidy"));
submap.put("sum_real_subsidy", (Integer)result.get("sum_real_subsidy"));
msmap.put((Long)result.get("merchant_id"), submap) ;
}
}
List<Map<String, Object>> resultList = wxCardSpendMapper.sumCardSpendVoForMerchant(record);
if (null != resultList && resultList.size() > 0 ) {
for (int i = 0 ; i < resultList.size(); i++) {
Map<String,Object> result = resultList.get(i);
Long merchantId = (Long)result.get("merchant_id") ;
if (null != merchantId) {
WxMerchant merchant = merchantMap.get(merchantId);
if (null != merchant) {
result.put("merchantName", merchant.getName());
}
Map<String,Integer> busmap = msmap.get(merchantId);
if (null != busmap) {
result.put("sum_subsidy", (null == busmap.get("sum_subsidy"))?0:busmap.get("sum_subsidy"));
result.put("sum_real_subsidy", (null == busmap.get("sum_real_subsidy")?0:busmap.get("sum_real_subsidy")));
}else {
result.put("sum_subsidy", 0);
result.put("sum_real_subsidy", 0);
}
}
}
}
return resultList;
}

private WxMerchantSubsidy getWxMerchantSubsidyQuery(WxCardSpendVo record,List<Long> merchantIdList) {
WxMerchantSubsidy sq = new WxMerchantSubsidy();
sq.updateTenantInfo(record);
sq.setStatus(record.getStatus());
sq.setSourceList(record.getSources());
sq.setCardSpendListShow(record.getCardSpendListShow());
if (null != merchantIdList && merchantIdList.size() > 0 ) {
sq.setMerchantIdList(merchantIdList);
}
return sq;
}
@Override
public List<Map<String, Object>> sumCardSpendForOwner(WxCardSpendVo record) {
return wxCardSpendMapper.sumCardSpendVoForOwner(record);
handleQueryParam(record);
List<Long> merchantIdList = wxCardSpendMapper.getMerchantIdList(record);
WxMerchantSubsidy sq = getWxMerchantSubsidyQuery(record,merchantIdList);
Map<String,Integer> submap = wxMerchantSubsidyMapper.sum(sq);
List<Map<String, Object>> resultList = wxCardSpendMapper.sumCardSpendVoForOwner(record);
if (null != resultList && resultList.size() > 0 ) {
for (int i = 0 ; i < resultList.size(); i++) {
Map<String,Object> result = resultList.get(i);
if (null != submap) {
result.put("sum_subsidy", (null == submap.get("sum_subsidy"))?0:submap.get("sum_subsidy"));
result.put("sum_real_subsidy", (null == submap.get("sum_real_subsidy")?0:submap.get("sum_real_subsidy")));
}else {
result.put("sum_subsidy", 0);
result.put("sum_real_subsidy", 0);
}
}
}
return resultList;
}

@Override


+ 19
- 21
mallinkService/src/main/resources/mapper/WxCardSpendMapper.xml Просмотреть файл

@@ -257,38 +257,36 @@
group by cs.merchant_id
</select>

<select id="getMerchantIdList" parameterType="com.iformall.domain.vo.WxCardSpendVo" resultType="Long">
select distinct cs.merchant_id
from wx_card_spend cs
<include refid="dynamicWhereConditions"/>
</select>

<select id="sumCardSpendVoForMerchant" parameterType="com.iformall.domain.vo.WxCardSpendVo" resultType="hashmap">
select cs.merchant_id, m.name as merchantName,
select cs.merchant_id,
IFNULL(SUM(cs.`deduction_amount`),0) as sum_deduction_amount,
IFNULL(SUM(cs.`payment`),0) as sum_payment,
IFNULL(SUM(cs.`real_payment`),0) as sum_real_payment,
IFNULL(SUM(ms.`subsidy`), 0) as sum_subsidy,
IFNULL(SUM(ms.`real_subsidy`), 0) as sum_real_subsidy
IFNULL(SUM(cs.`real_payment`),0) as sum_real_payment
from wx_card_spend cs
left join wx_coupon_order co on co.id = cs.card_id
left join wx_coupon c on c.id = co.coupon_id
left join wx_merchant m on m.id = cs.merchant_id
left join wx_merchant_subsidy ms on ms.order_id = cs.order_id
left join wx_c_user_basic_info ou on ou.id = co.owner_id
<include refid="dynamicVoWhereConditions"/>
<include refid="dynamicWhereConditions"/>
group by cs.merchant_id
</select>
<select id="sumCardSpendVoForOwner" parameterType="com.iformall.domain.vo.WxCardSpendVo" resultType="hashmap">
select cs.owner_id,
IFNULL(SUM(cs.`deduction_amount`),0) as sum_deduction_amount,
IFNULL(SUM(cs.`payment`),0) as sum_payment,
IFNULL(SUM(cs.`real_payment`),0) as sum_real_payment,
IFNULL(SUM(ms.`subsidy`), 0) as sum_subsidy,
IFNULL(SUM(ms.`real_subsidy`), 0) as sum_real_subsidy
IFNULL(SUM(cs.`real_payment`),0) as sum_real_payment
from wx_card_spend cs
left join wx_coupon_order co on co.id = cs.card_id
left join wx_coupon c on c.id = co.coupon_id
left join wx_merchant m on m.id = cs.merchant_id
left join wx_merchant_subsidy ms on ms.order_id = cs.order_id
left join wx_c_user_basic_info ou on ou.id = co.owner_id
<include refid="dynamicVoWhereConditions"/>
group by cs.owner_id
where cs.owner_id = #{ownerId}
<if test=" null != startdate">
and `create_date` &gt;= #{startdate}
</if>
<if test="null != enddate">
and `create_date` &lt;= and #{enddate}
</if>
order by cs.create_date desc
</select>

<select id="sumRealPayment" parameterType="com.iformall.domain.vo.WxCardSpendVo" resultType="Integer">


+ 23
- 1
mallinkService/src/main/resources/mapper/WxMerchantSubsidyMapper.xml Просмотреть файл

@@ -97,7 +97,12 @@
<if test=" null != cardSpendListShow ">
and ( card_spend_list_show is null or card_spend_list_show = #{cardSpendListShow} )
</if>
<if test=" null != merchantIdList ">
and `merchant_id` in
<foreach collection="merchantIdList" index="index" item="merchantIdItem" open="(" separator="," close=")">
#{merchantIdItem}
</foreach>
</if>
<if test=" null != sourceList ">
and (source is null or`source` in
<foreach collection="sourceList" index="index" item="sourceItem" open="(" separator="," close=")">
@@ -167,6 +172,23 @@
</foreach>
</if>
</update>
<select id="sumByMerchantId" parameterType="com.iformall.domain.po.WxMerchantSubsidy" resultType="HashMap">
select merchant_id,
IFNULL(SUM(ms.`subsidy`), 0) as sum_subsidy,
IFNULL(SUM(ms.`real_subsidy`), 0) as sum_real_subsidy
from wx_merchant_subsidy
<include refid="dynamicWhereConditions" />
group by merchant_id
</select>
<select id="sum" parameterType="com.iformall.domain.po.WxMerchantSubsidy" resultType="HashMap">
select
IFNULL(SUM(ms.`subsidy`), 0) as sum_subsidy,
IFNULL(SUM(ms.`real_subsidy`), 0) as sum_real_subsidy
from wx_merchant_subsidy
<include refid="dynamicWhereConditions" />
</select>


<resultMap id="VoBaseResultMap" type="com.iformall.domain.vo.WxMerchantSubsidyVo">


Загрузка…
Отмена
Сохранить