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

fix neupos

release_toaliyun_real
xiaohanzi 5 лет назад
Родитель
Сommit
14addb5937
4 измененных файлов: 90 добавлений и 250 удалений
  1. +1
    -214
      mallinkNeuPosAdmin/src/main/java/com/iformall/controller/BaseController.java
  2. +12
    -0
      mallinkNeuPosAdmin/src/main/java/com/iformall/controller/NeuPosAdminController.java
  3. +2
    -9
      mallinkService/src/main/java/com/iformall/domain/po/NeuPosOrderMasterExt.java
  4. +75
    -27
      mallinkService/src/main/resources/mapper/NeuPosOrderMasterExtMapper.xml

+ 1
- 214
mallinkNeuPosAdmin/src/main/java/com/iformall/controller/BaseController.java Просмотреть файл

@@ -44,24 +44,6 @@ public class BaseController {

private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private boolean isFmOpen;

@Autowired
private WxAppinfoService wxAppinfoService;

@Autowired
private FmOpenService openService;

@Autowired
private WxCUserBasicInfoService wxCUserBasicInfoService;

@Autowired
private WxCUserBasicChildService wxCUserBasicChildService;
@Autowired
private CUserTokenService cUserTokenService;
@Autowired
@Qualifier("objectCommonRedisTemplate")
RedisTemplate<String, Object> objectCommonRedisTemplate;
@@ -74,7 +56,7 @@ public class BaseController {
setValue(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(value));
} catch (ParseException e) {
try {
setValue(new SimpleDateFormat("yyyy-MM-dd ").parse(value));
setValue(new SimpleDateFormat("yyyy-MM-dd").parse(value));
} catch (ParseException e1) {
setValue(null);
}
@@ -88,202 +70,7 @@ public class BaseController {
});
}

@Deprecated
public String getTenantId() {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String tenantId = (String) request.getAttribute(Constant.TENANT_ID);
return tenantId;
}

public TenantEntity getTenantInfo() {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String tenantId = (String) request.getAttribute(Constant.TENANT_ID);
String parentTenantId = (String) request.getAttribute(Constant.PARENT_TENANT_ID);
TenantEntity tenantEntity = new TenantEntity() ;
tenantEntity.setTenantId(tenantId);
tenantEntity.setParentTenantId(parentTenantId);
return tenantEntity;
}

public String getFinalTenantId() {
TenantEntity tenantEntity = getTenantInfo();
return tenantEntity.getFinalTenantId();
}

public Long getMemberId() {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
Long memberId = (Long) request.getAttribute(Constant.LOGIN_MEMBER_KEY);
if(memberId == null){
throw new MallinkException(ErrorCode.USER_IS_NOT_MEMBER);
}
return memberId;
}

/**
* 微信端获取当前用户 wx_c_user,非会员
* 请尽量多用getTenantId, getUserId
*/
public WxCUser getWxCUser() {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
BaseCUserEntity baseuser = (BaseCUserEntity) request.getAttribute(Constant.REQUEST_C_USER_KEY);

if (baseuser == null) {
throw new MallinkException(ErrorCode.USER_IS_EMPTY);
}
if (baseuser.getRealUser() == null) {
throw new MallinkException(ErrorCode.USER_IS_EMPTY);
}
WxCUser user = RedisCacheUtils.getFieldObject(baseuser, "realUser", WxCUser.class);
TenantEntity tenantEntity = getTenantInfo();
if (user.getTenantId() == null) {
user.setTenantId(tenantEntity.getTenantId());
}
if (user.getParentTenantId() == null) {
user.setParentTenantId(tenantEntity.getParentTenantId());
}
return user;
}
public void removeCacheCUser() {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
BaseCUserEntity baseuser = (BaseCUserEntity) request.getAttribute(Constant.REQUEST_C_USER_KEY);
cUserTokenService.removeTokenCache(baseuser.getToken());
}
public void updateCacheCUser(String token,Object cuser) {
cUserTokenService.updateTokenCache(token, cuser);
}
private WxCUserBasicInfo getCacheMember(Long memberId,String finalTenantId,String key,long seconds) throws MallinkException {
// 缓存
WxCUserBasicInfo member = RedisCacheUtils.getCacheObject(objectCommonRedisTemplate, key, WxCUserBasicInfo.class);
if(null == member) {
member = wxCUserBasicInfoService.getById(memberId,finalTenantId);
if (member == null) {
throw new MallinkException(ErrorCode.USER_IS_EMPTY);
}
setCUserBasicChild(member);

RedisCacheUtils.cache(objectCommonRedisTemplate, key, member, seconds);
}
return member;
}
public WxCUserBasicInfo getCacheMember() throws MallinkException {
Long memberId = getMemberId();
String key = "webapp:member:"+memberId;
return getCacheMember(memberId,getFinalTenantId(), key, 3600*24*3);
}
/*此处缓存短暂时间,因为积分、成长值记录*/
public WxCUserBasicInfo getShortCacheMember(Long memberId,String finalTenantId) throws Exception {
String key = "webapp:short:member:"+memberId;
return getCacheMember(memberId,finalTenantId, key, 100);
}
public void removeCacheMember(Long memberId) {
String key = "webapp:member:"+memberId;
RedisCacheUtils.removeCache(objectCommonRedisTemplate, key);
String shortKey = "webapp:short:member:"+memberId;
RedisCacheUtils.removeCache(objectCommonRedisTemplate, shortKey);
}

public WxAppinfo getAppInfo(String appId) {
return wxAppinfoService.getByAppId(appId);
}

public WxMaService getWeappService(String appId) {
if(isFmOpen) {
return openService.getWxOpenComponentService().getWxMaServiceByAppid(appId);
} else {
WxAppinfo appinfo = wxAppinfoService.getByAppId(appId);
if (appinfo == null) {
return null;
}
WxMaService service = MaUtil.getWeappService(appinfo);
return service;
}

}

public WxMaService getWeappServiceByAppInfo(WxAppinfo appinfo) {
if(!isFmOpen) {
WxMaService service = MaUtil.getWeappService(appinfo);
return service;
}
return null;
}


public Long saveToBasicInfoByCUser(String userPhone,String userName,String avatarUrl,Integer sex,Long userId) {
TenantEntity tenantEntity = getTenantInfo();
if (StringUtils.isBlank(userPhone))
return null;

WxCUserBasicInfo byId = null;
if (null != userId) {
byId = wxCUserBasicInfoService.getById(userId,getFinalTenantId());
}

WxCUserBasicInfo basicInfo = wxCUserBasicInfoService.findInfoByPhone(tenantEntity, userPhone);

if (basicInfo != null) {
if (byId != null) {
if (!byId.getId().equals(basicInfo.getId())) {
//数据库存在此手机号的会员,并且当前微信存在另一手机号会员
logger.error("会员" + userId + "更换手机号时,当前手机号会员表已存在:" + userPhone);
return Long.valueOf(-1);
}
}
if (!basicInfo.getTenantId().contains("," + tenantEntity.getTenantId() + ",")) {
basicInfo.setTenantId(basicInfo.getTenantId() + tenantEntity.getTenantId() + ",");
}
basicInfo.setNickName(userName);
basicInfo.setAvatarUrl(avatarUrl);
basicInfo.setSex(sex);
wxCUserBasicInfoService.update(basicInfo);
removeCacheMember(basicInfo.getId());
return basicInfo.getId();
} else {
if (byId != null) {
if (!byId.getTenantId().contains("," + tenantEntity.getTenantId() + ",")) {
byId.setTenantId(byId.getTenantId() + tenantEntity.getTenantId() + ",");
}
byId.setPhone(userPhone);
byId.setNickName(userName);
byId.setAvatarUrl(avatarUrl);
byId.setSex(sex);
wxCUserBasicInfoService.update(byId);
removeCacheMember(basicInfo.getId());
return byId.getId();
} else {
basicInfo = new WxCUserBasicInfo();
basicInfo.setTenantId("," + tenantEntity.getTenantId() + ",");
basicInfo.setFinalTenantId(tenantEntity.getFinalTenantId());
basicInfo.setPhone(userPhone);
basicInfo.setNickName(userName);
basicInfo.setAvatarUrl(avatarUrl);
basicInfo.setSex(sex);
wxCUserBasicInfoService.save(basicInfo);
removeCacheMember(basicInfo.getId());
return basicInfo.getId();
}
}
}

public String getIpAddr() {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String ipaddress = IPUtil.getIpAddr(request);
return ipaddress;
}

private void setCUserBasicChild(WxCUserBasicInfo basicInfo){
WxCUserBasicChild child = new WxCUserBasicChild();
child.setCUserId(basicInfo.getId());
child.setTenantId(basicInfo.getFinalTenantId());
List<WxCUserBasicChild> list = wxCUserBasicChildService.findList(child);
basicInfo.setChildrenList(list);
}


}

+ 12
- 0
mallinkNeuPosAdmin/src/main/java/com/iformall/controller/NeuPosAdminController.java Просмотреть файл

@@ -6,6 +6,8 @@ import com.iformall.common.ResultData;
import com.iformall.domain.po.NeuPosOrderMasterExt;
import com.iformall.domain.po.WxActivity;
import com.iformall.service.NeuPosOrderService;
import com.iformall.utils.DateUtils;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@@ -66,6 +68,12 @@ public class NeuPosAdminController extends BaseController {
return new ResultData(maplist);
}
private void setDate(NeuPosOrderMasterExt example) {
if (null != example.getCreateEnd()) {
example.setCreateEnd(DateUtils.stringToDate(DateUtils.date2String(example.getCreateEnd(), "yyyy-MM-dd") +" 23:59:59","yyyy-MM-dd HH:mm:ss"));
}
}
@ApiOperation("集团类型流水")
@GetMapping("payTypeOrderlist")
@ApiImplicitParams({
@@ -76,6 +84,7 @@ public class NeuPosAdminController extends BaseController {
if (!tenantValid(tenantId)) {
return new ResultData(Result.ERROR,"未安装POS系统");
}
setDate(example);
example.setOrgId(24);
PageInfo<Map> maplist = neuPosOrderService.queryShopPayOrderList(example,pageNum,pageSize);
return new ResultData(maplist);
@@ -89,6 +98,7 @@ public class NeuPosAdminController extends BaseController {
if (!tenantValid(tenantId)) {
return new ResultData(Result.ERROR,"未安装POS系统");
}
setDate(example);
example.setOrgId(24);
List<Map> maplist = neuPosOrderService.queryShopPayOrderSum(example);
return new ResultData(maplist);
@@ -104,6 +114,7 @@ public class NeuPosAdminController extends BaseController {
if (!tenantValid(tenantId)) {
return new ResultData(Result.ERROR,"未安装POS系统");
}
setDate(example);
example.setOrgId(24);
PageInfo<Map> maplist = neuPosOrderService.queryShopPayTypeTradeList(example,pageNum,pageSize);
return new ResultData(maplist);
@@ -119,6 +130,7 @@ public class NeuPosAdminController extends BaseController {
if (!tenantValid(tenantId)) {
return new ResultData(Result.ERROR,"未安装POS系统");
}
setDate(example);
example.setOrgId(24);
PageInfo<Map> maplist = neuPosOrderService.queryOrderList(example,pageNum,pageSize);
return new ResultData(maplist);


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

@@ -1,13 +1,7 @@
package com.iformall.domain.po;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.iformall.domain.po.base.BaseEntity;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@@ -16,10 +10,9 @@ import lombok.ToString;
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class NeuPosOrderMasterExt extends BaseEntity{
private Integer orgId;
private static final long serialVersionUID = 6080005017786775288L;
private Integer orgId;
private Integer shopId;
@TableField(exist = false)
private Date createBegin;
@TableField(exist = false)
private Date createEnd;
}

+ 75
- 27
mallinkService/src/main/resources/mapper/NeuPosOrderMasterExtMapper.xml Просмотреть файл

@@ -6,8 +6,8 @@
SELECT shop_id as shopId,
sum(real_pay_amount) as payAmount,
count(0) as payCount
from order_master
where order_status = 2 and order_type != '3'
from order_master_v2
where order_status = 4 and order_type != '3'
<if test=" orgId != null">
and org_id = #{orgId}
</if>
@@ -32,8 +32,8 @@
count(if(order_status=4,true,null)) refundCount,
ifnull(sum(if(order_status=2,real_pay_amount,0)),0) as amount,
pay_type as payType
from order_master
where pay_status = 2 and order_type != '3'
from order_master_v2
where pay_status = 4 and order_type != '3'
<if test=" orgId != null">
and org_id = #{orgId}
</if>
@@ -50,27 +50,75 @@
</select>
<select id="queryShopPayOrderSum" parameterType="com.iformall.domain.po.NeuPosOrderMasterExt" resultType="java.util.Map">
select ifnull(sum(order_amount),0) as payAmount,
ifnull(sum(discount_amount),0) as discountAmount,
count(order_amount) as payCount,
ifnull(sum(if(order_status=4,real_pay_amount,0)),0) refundAmount,
count(if(order_status=4,true,null)) refundCount,
ifnull(sum(if(order_status=2,real_pay_amount,0)),0) as amount,
pay_type as payType
from order_master
where pay_status = 2 and order_type != '3'
<if test=" orgId != null">
and org_id = #{orgId}
</if>
<if test=" shopId != null">
and shop_id = #{shopId}
</if>
<if test=" createBegin != null">
and created_at &gt;= #{createBegin}
</if>
<if test=" createEnd != null">
and created_at &lt;= #{createEnd}
</if>
select _temp.payType as payType, sum(_temp.payAmount) as payAmount, sum(_temp.payCount) as payCount from
(
SELECT
ifnull( refund.shop_id, paid.shop_id ) AS shopId,
pay_type_dict_v2.pay_type AS payType,
ifnull( payAmount, 0 ) - ifnull( refundAmount, 0 ) AS payAmount,
ifnull( payCount, 0 ) + ifnull( refundCount, 0 ) AS payCount
FROM
pay_type_dict_v2
LEFT JOIN (
SELECT
shop_id,
pay_type AS payType,
ifnull( sum( pay_order_v2.pay_amount ) / 100, 0 ) AS payAmount,
count( 0 ) AS payCount,
0 AS discountAmount
FROM
pay_order_v2
LEFT JOIN order_master_v2 ON pay_order_v2.m_order_number = order_master_v2.order_number
<if test=" orgId != null">
and order_master_v2.org_id = #{orgId}
</if>
<if test=" shopId != null">
and order_master_v2.shop_id = #{shopId}
</if>
<if test=" createBegin != null">
and order_master_v2.created_at &gt;= #{createBegin}
</if>
<if test=" createEnd != null">
and order_master_v2.created_at &lt;= #{createEnd}
</if>
AND ( pay_order_v2.pay_status = 2 OR pay_order_v2.pay_status = 5 OR pay_order_v2.pay_status = 4 )
GROUP BY
pay_type,
shop_id
) AS paid ON pay_type_dict_v2.pay_type = paid.payType
LEFT JOIN (
SELECT
shop_id,
pay_type AS payType,
ifnull( sum( refunded_amount ) / 100, 0 ) refundAmount,
count( 0 ) refundCount
FROM
pay_refund_order_v2 AS pay_order_v2
LEFT JOIN order_master_v2 ON pay_order_v2.m_order_number = order_master_v2.order_number
<if test=" orgId != null">
and order_master_v2.org_id = #{orgId}
</if>
<if test=" shopId != null">
and order_master_v2.shop_id = #{shopId}
</if>
<if test=" createBegin != null">
and order_master_v2.created_at &gt;= #{createBegin}
</if>
<if test=" createEnd != null">
and order_master_v2.created_at &lt;= #{createEnd}
</if>
AND refund_status = 2
GROUP BY
pay_type,
shop_id
) AS refund ON pay_type_dict_v2.pay_type = refund.payType
AND paid.shop_id = refund.shop_id
ORDER BY
payType,
shopId ASC
) as _temp
where _temp.payType in (select pay_type from trade_mch_pay_channel where org_id = #{orgId})
group by _temp.payType
</select>
<select id="selectShopList" parameterType="Integer" resultType="java.util.Map">
@@ -88,8 +136,8 @@
<select id="queryOrderList" parameterType="com.iformall.domain.po.NeuPosOrderMasterExt" resultType="java.util.Map">
SELECT order_number as orderNumber, serial_no as serialNo, order_amount as orderAmount,real_pay_amount as realPayAmount,
discount_amount as discountAmount, pay_type as payType,paid_time as paidTime,order_status as orderStatus
from order_master
where order_status = 2 and order_type != '3'
from order_master_v2
where order_status = 4 and order_type != '3'
<if test=" orgId != null">
and org_id = #{orgId}
</if>


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