| @@ -1,5 +1,6 @@ | |||
| package com.iformall.controller; | |||
| import com.iformall.domain.vo.WxOrderQueryVo; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -15,6 +16,8 @@ import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import java.util.Map; | |||
| @RestController | |||
| @RequestMapping("wxOrder") | |||
| public class WxOrderController extends BaseController { | |||
| @@ -73,7 +76,34 @@ public class WxOrderController extends BaseController { | |||
| logger.debug("[" + getIpAddr() + "] WxOrderController::findById"); | |||
| return new ResultData(Result.SUCCESS,"查询成功",wxOrderService.getById(id)); | |||
| } | |||
| @ApiOperation("交易列表") | |||
| @GetMapping("listOrder") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true) | |||
| }) | |||
| public ResultData listOrder(@ModelAttribute WxOrderQueryVo wxOrderQueryVo, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxOrderController::listOrder"); | |||
| if (null == wxOrderQueryVo){ | |||
| wxOrderQueryVo = new WxOrderQueryVo(); | |||
| } | |||
| wxOrderQueryVo.setTenantId(getTenantId()); | |||
| final PageInfo<WxOrder> page = wxOrderService.listOrderAsPage(wxOrderQueryVo, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("交易统计") | |||
| @PostMapping("/queryOrderSummary") | |||
| public ResultData queryOrderSummary() { | |||
| logger.debug("[" + getIpAddr() + "] WxOrderController::queryOrderSummary"); | |||
| Map<String, Object> data = wxOrderService.queryOrderSummary(getTenantId()); | |||
| return new ResultData(data); | |||
| } | |||
| } | |||
| @@ -213,7 +213,7 @@ public class WxOrderController extends BaseController { | |||
| public ResultData list(@ModelAttribute WxOrder wxOrder, Integer pageNum, Integer pageSize) { | |||
| // c端用户应该只能看到自己的订单 | |||
| if (wxOrder == null) wxOrder = new WxOrder(); | |||
| wxOrder.setCUserId(getUser().getId()); | |||
| wxOrder.setcUserId(getUser().getId()); | |||
| wxOrder.setSortColumns(WxOrder.Field.CreateDate_DESC); | |||
| final PageInfo<WxOrderCouponVo> page = wxOrderService.listCUserVoAsPage(wxOrder, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| @@ -235,7 +235,7 @@ public class WxOrderController extends BaseController { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "订单ID转换异常"); | |||
| } | |||
| wxOrder.setId(id); | |||
| wxOrder.setCUserId(getUser().getId()); | |||
| wxOrder.setcUserId(getUser().getId()); | |||
| WxOrderCouponVo wxOrderCVo = wxOrderService.detailCUserVo(wxOrder); | |||
| if (wxOrderCVo == null) | |||
| return new ResultData(ErrorCode.ORDER_IS_NOT_FIND); | |||
| @@ -1,11 +1,11 @@ | |||
| package com.iformall.domain.po; | |||
| import javax.persistence.*; | |||
| import java.util.*; | |||
| import javax.persistence.Transient; | |||
| import java.util.List; | |||
| import javax.persistence.Id; | |||
| import javax.persistence.Table; | |||
| import javax.persistence.Transient; | |||
| import java.io.Serializable; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| @Table(name = "wx_order") | |||
| public class WxOrder implements Serializable { | |||
| @@ -38,8 +38,9 @@ public class WxOrder implements Serializable { | |||
| public void setIds(List<Long> ids) { | |||
| this.ids = ids; | |||
| } | |||
| @Transient | |||
| private String merchantName; | |||
| /*订单码;正反向交易保持一致。**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="订单码;正反向交易保持一致。",name="orderNumber") | |||
| @@ -90,19 +91,6 @@ public class WxOrder implements Serializable { | |||
| public void setTenantId(String _tenantId) { | |||
| tenantId = _tenantId; | |||
| } | |||
| public Long getCUserId() { | |||
| return cUserId; | |||
| } | |||
| public void setCUserId(Long _cUserId) { | |||
| cUserId = _cUserId; | |||
| } | |||
| public Long getPorductId() { | |||
| return productId; | |||
| } | |||
| public void setPorductId(Long _productId) { | |||
| this.productId = _productId; | |||
| } | |||
| public Integer getType() { | |||
| return type; | |||
| @@ -154,7 +142,29 @@ public class WxOrder implements Serializable { | |||
| detail = _detail; | |||
| } | |||
| public String getMerchantName() { | |||
| return merchantName; | |||
| } | |||
| public void setMerchantName(String merchantName) { | |||
| this.merchantName = merchantName; | |||
| } | |||
| public Long getcUserId() { | |||
| return cUserId; | |||
| } | |||
| public void setcUserId(Long cUserId) { | |||
| this.cUserId = cUserId; | |||
| } | |||
| public Long getProductId() { | |||
| return productId; | |||
| } | |||
| public void setProductId(Long productId) { | |||
| this.productId = productId; | |||
| } | |||
| public static enum Field | |||
| { | |||
| @@ -0,0 +1,54 @@ | |||
| package com.iformall.domain.vo; | |||
| import java.io.Serializable; | |||
| import java.util.Date; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| public class WxOrderQueryVo implements Serializable { | |||
| @io.swagger.annotations.ApiModelProperty(value="tenantId",name="tenantId") | |||
| private String tenantId; | |||
| @io.swagger.annotations.ApiModelProperty(value="商户名称",name="merchantName") | |||
| private String merchantName; | |||
| @io.swagger.annotations.ApiModelProperty(value="开始时间",name="startdate") | |||
| private Date startdate; | |||
| @io.swagger.annotations.ApiModelProperty(value="结束时间",name="enddate") | |||
| private Date enddate; | |||
| public String getTenantId() { | |||
| return tenantId; | |||
| } | |||
| public void setTenantId(String tenantId) { | |||
| this.tenantId = tenantId; | |||
| } | |||
| public String getMerchantName() { | |||
| return merchantName; | |||
| } | |||
| public void setMerchantName(String merchantName) { | |||
| this.merchantName = merchantName; | |||
| } | |||
| public Date getStartdate() { | |||
| return startdate; | |||
| } | |||
| public void setStartdate(Date startdate) { | |||
| this.startdate = startdate; | |||
| } | |||
| public Date getEnddate() { | |||
| return enddate; | |||
| } | |||
| public void setEnddate(Date enddate) { | |||
| this.enddate = enddate; | |||
| } | |||
| } | |||
| @@ -1,12 +1,12 @@ | |||
| package com.iformall.mapper; | |||
| import java.util.*; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.vo.MarkingSceneDataVo; | |||
| import com.iformall.domain.vo.WxOrderReportVo; | |||
| import com.iformall.domain.vo.WxOrderCouponVo; | |||
| import com.iformall.domain.po.WxOrder; | |||
| import com.iformall.domain.vo.WxOrderPayVo; | |||
| import com.iformall.domain.vo.*; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| public interface WxOrderMapper extends CommonMapper<WxOrder, Long> { | |||
| @@ -27,4 +27,10 @@ public interface WxOrderMapper extends CommonMapper<WxOrder, Long> { | |||
| List<MarkingSceneDataVo> queryForSceneRepotyHistory(HashMap<String,Object> params); | |||
| List<WxOrderReportVo> listOrderReportByDate(HashMap<String,Object> params); | |||
| List<WxOrder> findListOrder(WxOrderQueryVo record); | |||
| Long queryOrderForMerchantCount(Map<String,Object> params); | |||
| Long queryOrderForSum(Map<String,Object> params); | |||
| } | |||
| @@ -1,7 +1,5 @@ | |||
| package com.iformall.service; | |||
| import java.util.*; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxCUser; | |||
| @@ -9,8 +7,12 @@ import com.iformall.domain.po.WxCouponOrder; | |||
| import com.iformall.domain.po.WxMerchantBUser; | |||
| import com.iformall.domain.po.WxOrder; | |||
| import com.iformall.domain.vo.WxOrderCouponVo; | |||
| import com.iformall.domain.vo.WxOrderQueryVo; | |||
| import com.iformall.enums.EnumOrderStatus; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| public interface WxOrderService { | |||
| /** | |||
| @@ -135,4 +137,9 @@ public interface WxOrderService { | |||
| */ | |||
| void shareForMicroPay(String tenantId, Long orderId, Long payOrderId); | |||
| PageInfo<WxOrder> listOrderAsPage(WxOrderQueryVo wxOrder, Integer pageNum, Integer pageSize); | |||
| Map<String,Object> queryOrderSummary(String tenantId); | |||
| } | |||
| @@ -386,7 +386,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| WxOrder wxOrder = wxOrderMapper.selectByPrimaryKey(couponOrder.getOrderId()); | |||
| if (wxOrder != null) { | |||
| try { | |||
| return wxCouponSendService.sendCouponToUser(bUser.getTenantId(), wxOrder.getCUserId(), EnumCouponSendSendType.COUPON_VERIFY); | |||
| return wxCouponSendService.sendCouponToUser(bUser.getTenantId(), wxOrder.getcUserId(), EnumCouponSendSendType.COUPON_VERIFY); | |||
| } catch (Exception e) { | |||
| logger.error("核销发券: " + e.getMessage()); | |||
| } | |||
| @@ -438,7 +438,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_FOUND); | |||
| } | |||
| // 4. get user info | |||
| WxCUser user = wxCUserMapper.selectByPrimaryKey(order.getCUserId()); | |||
| WxCUser user = wxCUserMapper.selectByPrimaryKey(order.getcUserId()); | |||
| if (user == null) { | |||
| logger.error("找不到C端用户"); | |||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||
| @@ -9,10 +9,12 @@ import com.iformall.domain.po.*; | |||
| import com.iformall.domain.vo.WxMerchantVo; | |||
| import com.iformall.domain.vo.WxOrderCouponVo; | |||
| import com.iformall.domain.vo.WxOrderPayVo; | |||
| import com.iformall.domain.vo.WxOrderQueryVo; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.*; | |||
| import com.iformall.service.*; | |||
| import com.iformall.utils.DateUtils; | |||
| import com.iformall.utils.RedisLock; | |||
| import com.iformall.utils.Utility; | |||
| import org.slf4j.Logger; | |||
| @@ -161,9 +163,9 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| int countOrder = 0, countCouponOrder = 0; | |||
| WxOrder orderQ = new WxOrder(); | |||
| orderQ.setTenantId(user.getTenantId()); | |||
| orderQ.setPorductId(counpon.getId()); | |||
| orderQ.setProductId(counpon.getId()); | |||
| orderQ.setType(EnumOrderType.COUPON.getCode()); | |||
| orderQ.setCUserId(user.getId()); | |||
| orderQ.setcUserId(user.getId()); | |||
| orderQ.setOrderStatus(EnumOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode()); | |||
| try { | |||
| if (counpon.getType().equals(EnumCouponType.COUPON_TINGCHE.getCode())) { | |||
| @@ -252,7 +254,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| public void stockBack(WxOrder updateOrder) { | |||
| // 已取消/已退款,库存加1 | |||
| // 获取订单相关coupon | |||
| Long couponId = updateOrder.getPorductId(); | |||
| Long couponId = updateOrder.getProductId(); | |||
| String couponIdStr = "" + couponId; | |||
| //加锁 | |||
| long time = System.currentTimeMillis() + RedisLock.TIMEOUT; | |||
| @@ -349,9 +351,9 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| record.setId(orderNumber); | |||
| record.setTenantId(user.getTenantId()); | |||
| record.setOrderNumber(orderNumber); | |||
| record.setPorductId(couponId); | |||
| record.setProductId(couponId); | |||
| record.setType(EnumOrderType.COUPON.getCode()); | |||
| record.setCUserId(user.getId()); | |||
| record.setcUserId(user.getId()); | |||
| record.setPaymentType(EnumPayType.PAY_PAYMENT.getCode()); | |||
| record.setPayment(payment); | |||
| record.setOrderStatus(EnumOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode()); | |||
| @@ -420,7 +422,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| record.setTenantId(user.getTenantId()); | |||
| record.setOrderNumber(orderNumber); | |||
| record.setType(EnumOrderType.MICROPAY.getCode()); | |||
| record.setPorductId(user.getId()); | |||
| record.setProductId(user.getId()); | |||
| record.setPaymentType(EnumPayType.PAY_PAYMENT.getCode()); | |||
| record.setPayment(payment); | |||
| record.setOrderStatus(EnumOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode()); | |||
| @@ -476,7 +478,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| WxCouponOrder couponOrder = new WxCouponOrder(); | |||
| couponOrder.setId(idWorker.nextId()); | |||
| couponOrder.setTenantId(user.getTenantId()); | |||
| couponOrder.setCouponId(order.getPorductId()); | |||
| couponOrder.setCouponId(order.getProductId()); | |||
| couponOrder.setCUserId(user.getId()); | |||
| couponOrder.setOrderId(order.getOrderNumber()); | |||
| couponOrder.setExpiredTime(valid_date); | |||
| @@ -537,9 +539,9 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| record.setId(orderNumber); | |||
| record.setTenantId(user.getTenantId()); | |||
| record.setOrderNumber(orderNumber); | |||
| record.setPorductId(couponId); | |||
| record.setProductId(couponId); | |||
| record.setType(EnumOrderType.COUPON.getCode()); | |||
| record.setCUserId(user.getId()); | |||
| record.setcUserId(user.getId()); | |||
| record.setPaymentType(EnumPayType.PAY_PAYMENT.getCode()); | |||
| record.setPayment(payment); | |||
| record.setOrderStatus(EnumOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS.getCode()); | |||
| @@ -616,9 +618,9 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| record.setId(orderNumber); | |||
| record.setTenantId(user.getTenantId()); | |||
| record.setOrderNumber(orderNumber); | |||
| record.setPorductId(couponId); | |||
| record.setProductId(couponId); | |||
| record.setType(EnumOrderType.COUPON.getCode()); | |||
| record.setCUserId(user.getId()); | |||
| record.setcUserId(user.getId()); | |||
| record.setPaymentType(EnumPayType.PAY_PAYMENT.getCode()); | |||
| record.setPayment(payment); | |||
| record.setOrderStatus(EnumOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS.getCode()); | |||
| @@ -654,18 +656,18 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| public int couponOrderSuccess(WxOrder updateOrder) { | |||
| Date currentDate = new Date(); | |||
| WxCoupon coupon = wxCouponMapper.selectByPrimaryKey(updateOrder.getPorductId()); | |||
| WxCoupon coupon = wxCouponMapper.selectByPrimaryKey(updateOrder.getProductId()); | |||
| if (coupon == null) { | |||
| logger.error("券不存在, couponId: " + updateOrder.getPorductId()); | |||
| logger.error("券不存在, couponId: " + updateOrder.getProductId()); | |||
| throw new MallinkException(ErrorCode.COUPON_IS_EMPTY); | |||
| } | |||
| if (coupon.getStatus() == EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode()) { | |||
| logger.error("券已下架, couponId: " + updateOrder.getPorductId()); | |||
| logger.error("券已下架, couponId: " + updateOrder.getProductId()); | |||
| throw new MallinkException(ErrorCode.COUPON_IS_TAKE_OFF); | |||
| } | |||
| WxCUser user = wxCUserMapper.selectByPrimaryKey(updateOrder.getCUserId()); | |||
| WxCUser user = wxCUserMapper.selectByPrimaryKey(updateOrder.getcUserId()); | |||
| if (user == null) { | |||
| logger.error("用户不存在, userId: " + updateOrder.getCUserId()); | |||
| logger.error("用户不存在, userId: " + updateOrder.getcUserId()); | |||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||
| } | |||
| // 已支付,更新支付时间 | |||
| @@ -701,15 +703,15 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| public int microPayOrderSuccess(WxOrder updateOrder) { | |||
| Date currentDate = new Date(); | |||
| // C端用户 | |||
| WxCUser user = wxCUserMapper.selectByPrimaryKey(updateOrder.getCUserId()); | |||
| WxCUser user = wxCUserMapper.selectByPrimaryKey(updateOrder.getcUserId()); | |||
| if (user == null) { | |||
| logger.error("用户不存在, userId: " + updateOrder.getCUserId()); | |||
| logger.error("用户不存在, userId: " + updateOrder.getcUserId()); | |||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||
| } | |||
| // B端用户 | |||
| WxMerchantBUser bUser = wxMerchantBUserMapper.selectByPrimaryKey(updateOrder.getPorductId()); | |||
| WxMerchantBUser bUser = wxMerchantBUserMapper.selectByPrimaryKey(updateOrder.getProductId()); | |||
| if(bUser == null) { | |||
| logger.error("B端用户不存在, bUserId: " + updateOrder.getPorductId()); | |||
| logger.error("B端用户不存在, bUserId: " + updateOrder.getProductId()); | |||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||
| } | |||
| // 基于B端User查找merchant | |||
| @@ -851,7 +853,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| wxPayOrder.setPayOrderStatus(EnumPayStatus.PAY_STATUS_SUCCESS.getCode()); | |||
| wxPayOrder = wxPayOrderMapper.selectOne(wxPayOrder); | |||
| WxOrder wxOrder = wxOrderMapper.selectByPrimaryKey(orderId); | |||
| WxMerchantBUser wxMerchantBUser = wxMerchantBUserMapper.selectByPrimaryKey(wxOrder.getPorductId()); | |||
| WxMerchantBUser wxMerchantBUser = wxMerchantBUserMapper.selectByPrimaryKey(wxOrder.getProductId()); | |||
| if (wxPayOrder != null && wxMerchantBUser != null && | |||
| wxPayOrder.getShare().equals(EnumPayShare.YES.getCode())) { | |||
| @@ -864,4 +866,102 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| } | |||
| } | |||
| @Override | |||
| public PageInfo<WxOrder> listOrderAsPage(WxOrderQueryVo record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxOrderMapper.findListOrder(record)); | |||
| } | |||
| @Override | |||
| public Map<String, Object> queryOrderSummary(String tenantId) { | |||
| Map<String, Object> result = new HashMap<>(); | |||
| queryMerchantCount(tenantId, result); | |||
| queryOrderSummary(tenantId,result); | |||
| return result; | |||
| } | |||
| public void queryMerchantCount(String tenantId, Map<String, Object> result) { | |||
| //全部商户个数 | |||
| Map<String, Object> params = new HashMap<>(); | |||
| params.put("tenantId", tenantId); | |||
| Long allMerchantCount=wxOrderMapper.queryOrderForMerchantCount(params); | |||
| result.put("allMerchantCount",allMerchantCount); | |||
| //今日 | |||
| String systemTime = DateUtils.getSystemTime("yyyy-MM-dd"); | |||
| params.put("startdate", systemTime + " 00:00:00"); | |||
| params.put("enddate", systemTime + " 23:59:59"); | |||
| Long todayMerchantCount=wxOrderMapper.queryOrderForMerchantCount(params); | |||
| result.put("todayMerchantCount",todayMerchantCount); | |||
| //昨日 | |||
| String yesterday = DateUtils.getTimeBefore(1, new Date()); | |||
| params.put("startdate", yesterday + " 00:00:00"); | |||
| params.put("enddate", yesterday + " 23:59:59"); | |||
| Long yesterdayMerchantCount=wxOrderMapper.queryOrderForMerchantCount(params); | |||
| result.put("yesterdayMerchantCount",yesterdayMerchantCount); | |||
| //上周 | |||
| String lastweek = DateUtils.getTimeBefore(7, new Date()); | |||
| params.put("startdate", lastweek + " 00:00:00"); | |||
| params.put("enddate", lastweek + " 23:59:59"); | |||
| Long lastweekMerchantCount=wxOrderMapper.queryOrderForMerchantCount(params); | |||
| result.put("lastweekMerchantCount",lastweekMerchantCount); | |||
| //商户数日环比 | |||
| if (yesterdayMerchantCount > 0) { | |||
| double hbd = (double) (todayMerchantCount - yesterdayMerchantCount) / yesterdayMerchantCount * 100; | |||
| double hb = new BigDecimal(hbd).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); | |||
| result.put("increasedPercentMerchant", hb+"%"); | |||
| } else { | |||
| result.put("increasedPercentMerchant", "--"); | |||
| } | |||
| //商户数周同比 | |||
| if (lastweekMerchantCount > 0) { | |||
| double hbd = (double) (todayMerchantCount - lastweekMerchantCount) / lastweekMerchantCount * 100; | |||
| double hb = new BigDecimal(hbd).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); | |||
| result.put("increasedPercentWeekMerchant", hb+"%"); | |||
| } else { | |||
| result.put("increasedPercentWeekMerchant", "--"); | |||
| } | |||
| } | |||
| public void queryOrderSummary(String tenantId, Map<String, Object> result) { | |||
| //全部商户个数 | |||
| Map<String, Object> params = new HashMap<>(); | |||
| params.put("tenantId", tenantId); | |||
| Long allOrderSummary=wxOrderMapper.queryOrderForSum(params); | |||
| result.put("allOrderSummary",allOrderSummary); | |||
| //今日 | |||
| String systemTime = DateUtils.getSystemTime("yyyy-MM-dd"); | |||
| params.put("startdate", systemTime + " 00:00:00"); | |||
| params.put("enddate", systemTime + " 23:59:59"); | |||
| Long todayOrderSummary=wxOrderMapper.queryOrderForSum(params); | |||
| result.put("todayOrderSummary",todayOrderSummary); | |||
| //昨日 | |||
| String yesterday = DateUtils.getTimeBefore(1, new Date()); | |||
| params.put("startdate", yesterday + " 00:00:00"); | |||
| params.put("enddate", yesterday + " 23:59:59"); | |||
| Long yesterdayOrderSummary=wxOrderMapper.queryOrderForSum(params); | |||
| result.put("yesterdayOrderSummary",yesterdayOrderSummary); | |||
| //上周 | |||
| String lastweek = DateUtils.getTimeBefore(7, new Date()); | |||
| params.put("startdate", lastweek + " 00:00:00"); | |||
| params.put("enddate", lastweek + " 23:59:59"); | |||
| Long lastweekOrderSummary=wxOrderMapper.queryOrderForSum(params); | |||
| result.put("lastweekOrderSummary",lastweekOrderSummary); | |||
| //商户数日环比 | |||
| if (yesterdayOrderSummary > 0) { | |||
| double hbd = (double) (todayOrderSummary - yesterdayOrderSummary) / yesterdayOrderSummary * 100; | |||
| double hb = new BigDecimal(hbd).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); | |||
| result.put("increasedPercentSummary", hb+"%"); | |||
| } else { | |||
| result.put("increasedPercentSummary", "--"); | |||
| } | |||
| //商户数周同比 | |||
| if (lastweekOrderSummary > 0) { | |||
| double hbd = (double) (todayOrderSummary - lastweekOrderSummary) / lastweekOrderSummary * 100; | |||
| double hb = new BigDecimal(hbd).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); | |||
| result.put("increasedPercentWeekSummary", hb+"%"); | |||
| } else { | |||
| result.put("increasedPercentWeekSummary", "--"); | |||
| } | |||
| } | |||
| } | |||
| @@ -1287,7 +1287,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| } | |||
| // 修改订单状态 | |||
| order.setCUserId(userQ.getId()); | |||
| order.setcUserId(userQ.getId()); | |||
| try { | |||
| int _count = wxOrderService.microPayOrderSuccess(order); | |||
| if (_count > 1) { | |||
| @@ -1347,7 +1347,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND); | |||
| } | |||
| if (order.getType().equals(EnumOrderType.COUPON.getCode())) { | |||
| WxCUser user = wxCUserMapper.selectByPrimaryKey(order.getCUserId()); | |||
| WxCUser user = wxCUserMapper.selectByPrimaryKey(order.getcUserId()); | |||
| if (user == null) { | |||
| logger.error("pay handle, order " + record.getOrderId() + " not found , payOrderid : " + record.getPayOrderNo()); | |||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||
| @@ -235,7 +235,7 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| private boolean isMerchantOrder(WxOrder wxOrder, Long merchantId) { | |||
| if (wxOrder.getType().equals(EnumOrderType.COUPON.getCode())){ | |||
| WxCoupon wxCoupon = wxCouponMapper.selectByPrimaryKey(wxOrder.getPorductId()); | |||
| WxCoupon wxCoupon = wxCouponMapper.selectByPrimaryKey(wxOrder.getProductId()); | |||
| if (wxCoupon != null) { | |||
| WxCouponMerchant wxCouponMerchant = new WxCouponMerchant(); | |||
| wxCouponMerchant.setProductId(wxCoupon.getId()); | |||
| @@ -246,7 +246,7 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| } | |||
| } | |||
| }else if(wxOrder.getType().equals(EnumOrderType.MICROPAY.getCode())) { | |||
| WxMerchantBUser wxMerchantBUser = wxMerchantBUserMapper.selectByPrimaryKey(wxOrder.getPorductId()); | |||
| WxMerchantBUser wxMerchantBUser = wxMerchantBUserMapper.selectByPrimaryKey(wxOrder.getProductId()); | |||
| if (wxMerchantBUser != null && wxMerchantBUser.equals(merchantId)) { | |||
| return true; | |||
| } | |||
| @@ -285,7 +285,7 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| throw new MallinkException(ErrorCode.REFUND_ORDER_BUSER_IS_NULL); | |||
| } | |||
| if (isMerchantOrder(wxOrder, wxMerchantBUser.getMerchantId())) { | |||
| logger.error("订单: productId-" + wxOrder.getPorductId() + "退款: couponMerchantId-" + wxMerchantBUser.getMerchantId()); | |||
| logger.error("订单: productId-" + wxOrder.getProductId() + "退款: couponMerchantId-" + wxMerchantBUser.getMerchantId()); | |||
| throw new MallinkException(ErrorCode.REFUND_ORDER_BUSER_NOT_EQUAL); | |||
| } | |||
| } else if (payType == EnumPayType.PAY_ADMIN_REFUND) { | |||
| @@ -322,11 +322,11 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| rOrder.setId(refundOrderId); | |||
| rOrder.setTenantId(appInfo.getTenantId()); | |||
| rOrder.setOrderNumber(wxOrder.getOrderNumber()); // 退款订单填写支付订单orderNumber | |||
| rOrder.setPorductId(wxOrder.getPorductId()); | |||
| rOrder.setProductId(wxOrder.getProductId()); | |||
| rOrder.setType(EnumOrderType.COUPON.getCode()); | |||
| rOrder.setCUserId(wxOrder.getCUserId()); | |||
| rOrder.setcUserId(wxOrder.getcUserId()); | |||
| if (payType == EnumPayType.PAY_B_REFUND) { | |||
| rOrder.setPorductId(bUserId); //B端发起退款后存B端用户ID在此 | |||
| rOrder.setProductId(bUserId); //B端发起退款后存B端用户ID在此 | |||
| } | |||
| rOrder.setPaymentType(payType.getCode()); | |||
| rOrder.setPayment(wxOrder.getPayment()); | |||
| @@ -358,7 +358,7 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| // 查找支付订单 | |||
| WxPayOrder payOrderQ = new WxPayOrder(); | |||
| payOrderQ.setTenantId(appInfo.getTenantId()); | |||
| payOrderQ.setcUserId(wxOrder.getCUserId()); | |||
| payOrderQ.setcUserId(wxOrder.getcUserId()); | |||
| payOrderQ.setOrderId(wxOrder.getId()); | |||
| payOrderQ.setPayOrderStatus(EnumPayStatus.PAY_STATUS_SUCCESS.getCode()); | |||
| @@ -649,7 +649,7 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| throw new MallinkException(ErrorCode.REFUND_ORDER_BUSER_IS_NULL); | |||
| } | |||
| if (isMerchantOrder(wxOrder, wxMerchantBUser.getMerchantId())) { | |||
| logger.error("订单: productId-" + wxOrder.getPorductId() + "退款: MerchantId-" + wxMerchantBUser.getMerchantId()); | |||
| logger.error("订单: productId-" + wxOrder.getProductId() + "退款: MerchantId-" + wxMerchantBUser.getMerchantId()); | |||
| throw new MallinkException(ErrorCode.REFUND_ORDER_BUSER_NOT_EQUAL); | |||
| } | |||
| } else if (payType == EnumPayType.PAY_ADMIN_REFUND) { | |||
| @@ -674,9 +674,9 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| rOrder.setTenantId(appInfo.getTenantId()); | |||
| rOrder.setOrderNumber(wxOrder.getOrderNumber()); // 退款订单填写支付订单orderNumber | |||
| rOrder.setType(EnumOrderType.MICROPAY.getCode()); | |||
| rOrder.setCUserId(wxOrder.getCUserId()); | |||
| rOrder.setcUserId(wxOrder.getcUserId()); | |||
| if (payType == EnumPayType.PAY_B_REFUND) { | |||
| rOrder.setPorductId(bUserId); //B端发起退款后存B端用户ID在此 | |||
| rOrder.setProductId(bUserId); //B端发起退款后存B端用户ID在此 | |||
| } | |||
| rOrder.setPaymentType(payType.getCode()); | |||
| rOrder.setPayment(wxOrder.getPayment()); | |||
| @@ -693,7 +693,7 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| // 查找支付订单 | |||
| WxPayOrder payOrderQ = new WxPayOrder(); | |||
| payOrderQ.setTenantId(appInfo.getTenantId()); | |||
| payOrderQ.setcUserId(wxOrder.getCUserId()); | |||
| payOrderQ.setcUserId(wxOrder.getcUserId()); | |||
| payOrderQ.setOrderId(wxOrder.getId()); | |||
| payOrderQ.setPayOrderStatus(EnumPayStatus.PAY_STATUS_SUCCESS.getCode()); | |||
| @@ -212,7 +212,7 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { | |||
| addScoreNumber = dScoreT.intValue(); | |||
| // 5. 增长的成长值 | |||
| updateScore(order.getCUserId(), addScoreNumber); | |||
| updateScore(order.getcUserId(), addScoreNumber); | |||
| // 6. 记录历史 | |||
| recordPayScoreHistory(addScoreNumber, order, EnumScoreType.CONSUMPTION); | |||
| @@ -352,7 +352,7 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { | |||
| WxScoreHistory history = new WxScoreHistory(); | |||
| history.setId(idWorker.nextId()); | |||
| history.setTenantId(order.getTenantId()); | |||
| history.setCUserId(order.getCUserId()); | |||
| history.setCUserId(order.getcUserId()); | |||
| history.setCreateDate(new Date()); | |||
| history.setScoreType(EnumScoreType.CONSUMPTION.getCode()); | |||
| history.setOrderId(order.getId()); | |||
| @@ -322,5 +322,102 @@ | |||
| </if> | |||
| group by xTime | |||
| </select> | |||
| <resultMap id="orderMap" type="com.iformall.domain.po.WxOrder"> | |||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||
| <result column="order_number" jdbcType="BIGINT" property="orderNumber"/> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||
| <result column="c_user_id" jdbcType="BIGINT" property="cUserId"/> | |||
| <result column="product_id" jdbcType="BIGINT" property="productId"/> | |||
| <result column="type" jdbcType="TINYINT" property="type"/> | |||
| <result column="payment_type" jdbcType="INTEGER" property="paymentType"/> | |||
| <result column="payment" jdbcType="INTEGER" property="payment"/> | |||
| <result column="payment_time" jdbcType="TIMESTAMP" property="paymentTime"/> | |||
| <result column="order_status" jdbcType="INTEGER" property="orderStatus"/> | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/> | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> | |||
| <result column="detail" jdbcType="VARCHAR" property="detail"/> | |||
| <result column="merchant_name" jdbcType="VARCHAR" property="merchantName"/> | |||
| </resultMap> | |||
| <select id="findListOrder" resultMap="orderMap" parameterType="com.iformall.domain.vo.WxOrderQueryVo"> | |||
| select o.* from ( | |||
| select o.*,m.`name` merchant_name from ( | |||
| select o.*,cm.merchant_id from wx_order o | |||
| left join wx_coupon_merchant cm on o.product_id=cm.product_id | |||
| where type in (0,3)) o | |||
| left join wx_merchant m on o.merchant_id=m.id | |||
| union all | |||
| select o.*,m.`name` merchantName from ( | |||
| select o.*,mbu.merchant_id from wx_order o | |||
| left join wx_merchant_b_user mbu on o.product_id=mbu.id | |||
| where type in (1,2)) o | |||
| left join wx_merchant m on o.merchant_id=m.id | |||
| ) o | |||
| <where> | |||
| <if test="tenantId!=null"> | |||
| and o.tenant_id =#{tenantId} | |||
| </if> | |||
| <if test="merchantName!=null"> | |||
| and o.`merchant_name` like concat('%',#{merchantName},'%') | |||
| </if> | |||
| <if test="startdate!=null and enddate!=null"> | |||
| and o.create_date between #{startdate} and #{enddate} | |||
| </if> | |||
| </where> | |||
| order by o.id desc | |||
| </select> | |||
| <select id="queryOrderForMerchantCount" resultType="Long" parameterType="hashmap"> | |||
| select count(*) merchantCount from ( | |||
| select distinct merchant_id from ( | |||
| select o.*,m.`name` merchantName from ( | |||
| select o.*,cm.merchant_id from wx_order o | |||
| left join wx_coupon_merchant cm on o.product_id=cm.product_id | |||
| where type in (0,3)) o | |||
| left join wx_merchant m on o.merchant_id=m.id | |||
| union all | |||
| select o.*,m.`name` merchantName from ( | |||
| select o.*,mbu.merchant_id from wx_order o | |||
| left join wx_merchant_b_user mbu on o.product_id=mbu.id | |||
| where type in (1,2)) o | |||
| left join wx_merchant m on o.merchant_id=m.id | |||
| ) o | |||
| <where> | |||
| <if test="tenantId!=null"> | |||
| and tenant_id =#{tenantId} | |||
| </if> | |||
| <if test="startdate!=null and enddate!=null"> | |||
| and create_date between #{startdate} and #{enddate} | |||
| </if> | |||
| </where> | |||
| ) o | |||
| </select> | |||
| <select id="queryOrderForSum" resultType="Long" parameterType="hashmap"> | |||
| select ifnull(sum(payment),0) payment from ( | |||
| select o.*,m.`name` merchantName from ( | |||
| select o.*,cm.merchant_id from wx_order o | |||
| left join wx_coupon_merchant cm on o.product_id=cm.product_id | |||
| where type in (0,3)) o | |||
| left join wx_merchant m on o.merchant_id=m.id | |||
| union all | |||
| select o.*,m.`name` merchantName from ( | |||
| select o.*,mbu.merchant_id from wx_order o | |||
| left join wx_merchant_b_user mbu on o.product_id=mbu.id | |||
| where type in (1,2)) o | |||
| left join wx_merchant m on o.merchant_id=m.id | |||
| ) o | |||
| <where> | |||
| <if test="tenantId!=null"> | |||
| and tenant_id =#{tenantId} | |||
| </if> | |||
| <if test="startdate!=null and enddate!=null"> | |||
| and create_date between #{startdate} and #{enddate} | |||
| </if> | |||
| </where> | |||
| </select> | |||
| </mapper> | |||