未知的修改功能
This commit is contained in:
@@ -50,7 +50,8 @@ public class LoginFilter implements Filter {
|
||||
"cashierService/product/productInfo",
|
||||
"cashierService/notify/**",//登录部分接口不校验
|
||||
"notify/**",
|
||||
"cashierService/table/**"//回调部分接口不校验
|
||||
"cashierService/table/**",//回调部分接口不校验
|
||||
"cashierService/pay/**"
|
||||
);
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
package com.chaozhanggui.system.cashierservice.controller;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.ReturnGroupOrderDto;
|
||||
import com.chaozhanggui.system.cashierservice.service.PayService;
|
||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
import com.chaozhanggui.system.cashierservice.util.IpUtil;
|
||||
import com.chaozhanggui.system.cashierservice.util.TokenUtil;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@CrossOrigin(origins = "*")
|
||||
@@ -31,19 +28,18 @@ public class PayController {
|
||||
/**
|
||||
* 支付
|
||||
*
|
||||
* @param request
|
||||
* payType wechatPay:微信支付;aliPay:支付宝支付;
|
||||
* @param request payType wechatPay:微信支付;aliPay:支付宝支付;
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("orderPay")
|
||||
public Result pay(HttpServletRequest request, @RequestHeader("openId") String openId, @RequestBody Map<String,String> map) {
|
||||
if(ObjectUtil.isEmpty(map)||map.size()<=0||!map.containsKey("orderId")||ObjectUtil.isEmpty(map.get("orderId"))){
|
||||
public Result pay(HttpServletRequest request, @RequestHeader("openId") String openId, @RequestBody Map<String, String> map) {
|
||||
if (ObjectUtil.isEmpty(map) || map.size() <= 0 || !map.containsKey("orderId") || ObjectUtil.isEmpty(map.get("orderId"))) {
|
||||
return Result.fail("订单号不允许为空");
|
||||
}
|
||||
|
||||
try {
|
||||
return payService.payOrder(openId,map.get("orderId").toString(), IpUtil.getIpAddr(request));
|
||||
return payService.payOrder(openId, map.get("orderId"), IpUtil.getIpAddr(request));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -51,10 +47,9 @@ public class PayController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 储值卡支付
|
||||
*
|
||||
* @param token
|
||||
* @param orderId
|
||||
* @param memberId
|
||||
@@ -64,26 +59,26 @@ public class PayController {
|
||||
public Result accountPay(@RequestHeader("token") String token,
|
||||
@RequestParam("orderId") String orderId,
|
||||
@RequestParam("memberId") String memberId
|
||||
){
|
||||
return payService.accountPay(orderId,memberId,token);
|
||||
) {
|
||||
return payService.accountPay(orderId, memberId, token);
|
||||
}
|
||||
|
||||
@RequestMapping("groupOrderPay")
|
||||
public Result groupOrderPay(HttpServletRequest request, @RequestHeader String environment,@RequestHeader String token, @RequestBody Map<String, String> map) {
|
||||
public Result groupOrderPay(HttpServletRequest request, @RequestHeader String environment, @RequestHeader String token, @RequestBody Map<String, String> map) {
|
||||
if (ObjectUtil.isEmpty(map) || map.size() <= 0 || !map.containsKey("orderId") || ObjectUtil.isEmpty(map.get("orderId"))) {
|
||||
return Result.fail("订单号不允许为空");
|
||||
}
|
||||
String orderId = map.get("orderId").toString();
|
||||
String orderId = map.get("orderId");
|
||||
// String orderType = map.get("orderType").toString();
|
||||
String payType = map.get("payType").toString();
|
||||
String userId="";
|
||||
if(environment.equals("wx")){
|
||||
String payType = map.get("payType");
|
||||
String userId = "";
|
||||
if (environment.equals("wx")) {
|
||||
userId = TokenUtil.parseParamFromToken(token).getString("openId");
|
||||
}else {
|
||||
} else {
|
||||
userId = TokenUtil.parseParamFromToken(token).getString("userId");
|
||||
}
|
||||
//订单支付 orderId:62,payType=wechatPay,userId:or1l860rwM-rU_j9KrgMOwued
|
||||
log.info("订单支付 orderId:{},payType={},userId:{}",orderId,payType,userId);
|
||||
log.info("订单支付 orderId:{},payType={},userId:{}", orderId, payType, userId);
|
||||
try {
|
||||
// if(StringUtils.isNotBlank(orderType) && orderType.equals("group")){
|
||||
// return payService.groupOrderPay(orderId, payType, userId, IpUtil.getIpAddr(request));
|
||||
@@ -132,8 +127,8 @@ public class PayController {
|
||||
@RequestHeader("token") String token,
|
||||
@RequestParam("shopId") String shopId,
|
||||
@RequestParam("page") int page,
|
||||
@RequestParam("pageSize") int pageSize){
|
||||
return payService.getActivate(shopId,page,pageSize);
|
||||
@RequestParam("pageSize") int pageSize) {
|
||||
return payService.getActivate(shopId, page, pageSize);
|
||||
|
||||
}
|
||||
|
||||
@@ -149,7 +144,22 @@ public class PayController {
|
||||
public Result memeberIn(HttpServletRequest request, @RequestHeader("openId") String openId, @RequestHeader("id") String id,
|
||||
@RequestBody Map<String, Object> map
|
||||
) {
|
||||
return payService.memberIn(openId, id, map.get("amount").toString(), map.get("shopId").toString(), IpUtil.getIpAddr(request));
|
||||
try {
|
||||
return payService.memberIn(openId, id, map.get("amount").toString(), map.get("shopId").toString(), IpUtil.getIpAddr(request));
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("getShopByMember")
|
||||
public Result getShopByMember(@RequestHeader("token") String token,
|
||||
@RequestParam("page") int page,
|
||||
@RequestParam("pageSize") int pageSize,
|
||||
@RequestParam("userId") String userId,
|
||||
@RequestParam("shopId") String shopId
|
||||
) {
|
||||
return payService.getShopByMember(userId,shopId,page,pageSize);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
package com.chaozhanggui.system.cashierservice.dao;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbMerchantAccount;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Mapper
|
||||
public interface TbMerchantAccountMapper {
|
||||
|
||||
TbMerchantAccount selectByAccount(String account);
|
||||
|
||||
@@ -6,6 +6,9 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
@Mapper
|
||||
public interface TbShopUserMapper {
|
||||
@@ -25,7 +28,7 @@ public interface TbShopUserMapper {
|
||||
TbShopUser selectByUserIdAndShopId(@Param("userId") String userId,@Param("shopId") String shopId);
|
||||
|
||||
|
||||
TbShopUser selectByUserId(@Param("userId") String userId);
|
||||
List<Map<String,Object>> selectByUserId(@Param("userId") String userId,@Param("shopId") String shopId);
|
||||
|
||||
TbShopUser selectByOpenId(@Param("openId") String openId);
|
||||
|
||||
|
||||
@@ -45,9 +45,6 @@ public class TbShopUser implements Serializable {
|
||||
|
||||
private String dynamicCode;
|
||||
|
||||
private String isPwd;
|
||||
|
||||
private String pwd;
|
||||
|
||||
private Byte isAttention;
|
||||
|
||||
@@ -229,21 +226,6 @@ public class TbShopUser implements Serializable {
|
||||
this.dynamicCode = dynamicCode;
|
||||
}
|
||||
|
||||
public String getIsPwd() {
|
||||
return isPwd;
|
||||
}
|
||||
|
||||
public void setIsPwd(String isPwd) {
|
||||
this.isPwd = isPwd;
|
||||
}
|
||||
|
||||
public String getPwd() {
|
||||
return pwd;
|
||||
}
|
||||
|
||||
public void setPwd(String pwd) {
|
||||
this.pwd = pwd;
|
||||
}
|
||||
|
||||
public Byte getIsAttention() {
|
||||
return isAttention;
|
||||
|
||||
@@ -99,6 +99,15 @@ public class TbUserInfo implements Serializable {
|
||||
|
||||
private String phone="";
|
||||
|
||||
|
||||
private String isPwd;
|
||||
|
||||
private String pwd;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
@@ -484,4 +493,20 @@ public class TbUserInfo implements Serializable {
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getIsPwd() {
|
||||
return isPwd;
|
||||
}
|
||||
|
||||
public void setIsPwd(String isPwd) {
|
||||
this.isPwd = isPwd;
|
||||
}
|
||||
|
||||
public String getPwd() {
|
||||
return pwd;
|
||||
}
|
||||
|
||||
public void setPwd(String pwd) {
|
||||
this.pwd = pwd;
|
||||
}
|
||||
}
|
||||
@@ -77,6 +77,8 @@ public class LoginService {
|
||||
userInfo.setSourcePath("WECHAT-APP");
|
||||
userInfo.setIsAttentionMp(Byte.parseByte("0"));
|
||||
userInfo.setSearchWord("||微信用户");
|
||||
userInfo.setIsPwd("0");
|
||||
userInfo.setPwd(MD5Utils.md5("123456"));
|
||||
userInfo.setLastLogInAt(System.currentTimeMillis());
|
||||
userInfo.setCreatedAt(System.currentTimeMillis());
|
||||
userInfo.setUpdatedAt(System.currentTimeMillis());
|
||||
@@ -276,8 +278,7 @@ public class LoginService {
|
||||
public Result resetPwd(String userId,Map<String,Object> map){
|
||||
if(ObjectUtil.isNull(map)||ObjectUtil.isEmpty(map)||!map.containsKey("pwd")
|
||||
||ObjectUtil.isEmpty(map.get("pwd"))||!map.containsKey("code")
|
||||
||ObjectUtil.isEmpty(map.get("code"))||
|
||||
!map.containsKey("shopId")||ObjectUtil.isEmpty(map.get("shopId"))
|
||||
||ObjectUtil.isEmpty(map.get("code"))
|
||||
){
|
||||
return Result.fail("参数错误");
|
||||
}
|
||||
@@ -289,16 +290,10 @@ public class LoginService {
|
||||
}
|
||||
|
||||
|
||||
TbShopUser user=tbShopUserMapper.selectByUserIdAndShopId(userId,map.get("shopId").toString());
|
||||
if(ObjectUtil.isEmpty(user)||ObjectUtil.isNull(user)){
|
||||
return Result.fail("店铺用户信息不存在");
|
||||
}
|
||||
|
||||
|
||||
user.setIsPwd("1");
|
||||
user.setPwd(MD5Utils.md5(map.get("pwd").toString()));
|
||||
user.setUpdatedAt(System.currentTimeMillis());
|
||||
tbShopUserMapper.updateByPrimaryKey(user);
|
||||
userInfo.setIsPwd("1");
|
||||
userInfo.setPwd(MD5Utils.md5(map.get("pwd").toString()));
|
||||
userInfo.setUpdatedAt(System.currentTimeMillis());
|
||||
tbUserInfoMapper.updateByPrimaryKey(userInfo);
|
||||
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
|
||||
@@ -309,26 +304,25 @@ public class LoginService {
|
||||
public Result modifyPwd(String userId,Map<String,Object> map){
|
||||
if(ObjectUtil.isNull(map)||ObjectUtil.isEmpty(map)||!map.containsKey("pwd")
|
||||
||ObjectUtil.isEmpty(map.get("pwd"))||!map.containsKey("oldpwd")
|
||||
||ObjectUtil.isEmpty(map.get("oldpwd"))||
|
||||
!map.containsKey("shopId")||ObjectUtil.isEmpty(map.get("shopId"))
|
||||
||ObjectUtil.isEmpty(map.get("oldpwd"))
|
||||
){
|
||||
return Result.fail("参数错误");
|
||||
}
|
||||
|
||||
TbShopUser user=tbShopUserMapper.selectByUserIdAndShopId(userId,map.get("shopId").toString());
|
||||
if(ObjectUtil.isEmpty(user)||ObjectUtil.isNull(user)){
|
||||
return Result.fail("店铺用户信息不存在");
|
||||
TbUserInfo userInfo=tbUserInfoMapper.selectByPrimaryKey(Integer.valueOf(userId));
|
||||
if(ObjectUtil.isEmpty(userInfo)||ObjectUtil.isNull(userInfo)){
|
||||
return Result.fail("用户基本信息不存在");
|
||||
}
|
||||
|
||||
if(!user.getPwd().equals(MD5Utils.md5(map.get("oldpwd").toString()))){
|
||||
if(!userInfo.getPwd().equals(MD5Utils.md5(map.get("oldpwd").toString()))){
|
||||
return Result.fail("用户旧密码错误");
|
||||
}
|
||||
|
||||
|
||||
user.setIsPwd("1");
|
||||
user.setPwd(MD5Utils.md5(map.get("pwd").toString()));
|
||||
user.setUpdatedAt(System.currentTimeMillis());
|
||||
tbShopUserMapper.updateByPrimaryKey(user);
|
||||
userInfo.setIsPwd("1");
|
||||
userInfo.setPwd(MD5Utils.md5(map.get("pwd").toString()));
|
||||
userInfo.setUpdatedAt(System.currentTimeMillis());
|
||||
tbUserInfoMapper.updateByPrimaryKey(userInfo);
|
||||
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
|
||||
|
||||
@@ -125,6 +125,9 @@ public class PayService {
|
||||
@Autowired
|
||||
ThirdPayService thirdPayService;
|
||||
|
||||
@Autowired
|
||||
TbUserInfoMapper tbUserInfoMapper;
|
||||
|
||||
|
||||
|
||||
@Resource
|
||||
@@ -715,11 +718,15 @@ public class PayService {
|
||||
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Result memberIn(String openId,String userId,String amount,String shopId,String ip){
|
||||
public Result memberIn(String openId,String userId,String amount,String shopId,String ip) throws JsonProcessingException {
|
||||
if(ObjectUtil.isEmpty(openId)||ObjectUtil.isEmpty(userId)){
|
||||
return Result.fail("用户信息允许为空");
|
||||
}
|
||||
|
||||
TbUserInfo userInfo= tbUserInfoMapper.selectByPrimaryKey(Integer.valueOf(userId));
|
||||
if(ObjectUtil.isEmpty(userInfo)){
|
||||
return Result.fail("用户基本信息不存在");
|
||||
}
|
||||
|
||||
TbShopUser tbShopUser= tbShopUserMapper.selectByUserIdAndShopId(userId,shopId);
|
||||
if(ObjectUtil.isEmpty(tbShopUser)){
|
||||
@@ -727,7 +734,7 @@ public class PayService {
|
||||
}
|
||||
|
||||
|
||||
if("0".equals(tbShopUser.getIsPwd())){
|
||||
if("0".equals(userInfo.getIsPwd())){
|
||||
return Result.fail("用户支付密码未设置");
|
||||
}
|
||||
|
||||
@@ -789,18 +796,19 @@ public class PayService {
|
||||
}
|
||||
}
|
||||
}else {
|
||||
PublicResp<WxScanPayResp> publicResp= thirdPayService.scanpay(thirdUrl,thirdApply.getAppId(),"会员充值","会员充值",new BigDecimal(amount).setScale(2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)).longValue(),"WECHAT",thirdApply.getSmallAppid(),userId,ip, DateUtils.getsdfTimesSS(),thirdApply.getStoreId(),callInBack,null,thirdApply.getAppToken());
|
||||
String orderNo=DateUtils.getsdfTimesSS();
|
||||
PublicResp<WxScanPayResp> publicResp= thirdPayService.scanpay(thirdUrl,thirdApply.getAppId(),"会员充值","会员充值",new BigDecimal(amount).setScale(2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)).longValue(),"WECHAT",thirdApply.getSmallAppid(),openId,ip, orderNo,thirdApply.getStoreId(),callInBack,null,thirdApply.getAppToken());
|
||||
if(ObjectUtil.isNotNull(publicResp)&&ObjectUtil.isNotEmpty(publicResp)){
|
||||
if("000000".equals(publicResp.getCode())){
|
||||
WxScanPayResp wxScanPayResp= publicResp.getObjData();
|
||||
if("TRADE_SUCCESS".equals(wxScanPayResp.getState())){
|
||||
if("TRADE_AWAIT".equals(wxScanPayResp.getState())){
|
||||
|
||||
memberIn.setOrderNo(wxScanPayResp.getPayOrderId());
|
||||
memberIn.setOrderNo(orderNo);
|
||||
memberIn.setTradeNo(wxScanPayResp.getPayOrderId());
|
||||
memberIn.setUpdateTime(new Date());
|
||||
tbMemberInMapper.updateByPrimaryKeySelective(memberIn);
|
||||
|
||||
return Result.success(CodeEnum.SUCCESS,wxScanPayResp.getPayInfo());
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
return Result.success(CodeEnum.SUCCESS,mapper.readTree(wxScanPayResp.getPayInfo()));
|
||||
|
||||
}else{
|
||||
return Result.fail(publicResp.getMsg());
|
||||
@@ -936,6 +944,15 @@ public class PayService {
|
||||
|
||||
|
||||
|
||||
public Result getShopByMember(String userId,String shopId,int page,int pageSize){
|
||||
PageHelper.startPage(page, pageSize);
|
||||
List<Map<String,Object>> list= tbShopUserMapper.selectByUserId(userId,shopId);
|
||||
PageInfo pageInfo=new PageInfo(list);
|
||||
return Result.success(CodeEnum.SUCCESS,pageInfo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@@ -1040,6 +1057,10 @@ public class PayService {
|
||||
return "充值记录不存在";
|
||||
}
|
||||
|
||||
if(!"7".equals(memberIn.getStatus())){
|
||||
return "订单已处理";
|
||||
}
|
||||
|
||||
memberIn.setTradeNo(tradeNo);
|
||||
memberIn.setStatus("0");
|
||||
memberIn.setUpdateTime(new Date());
|
||||
@@ -1051,6 +1072,7 @@ public class PayService {
|
||||
}
|
||||
|
||||
if(!"1".equals(tbShopUser.getIsVip().toString())){
|
||||
tbShopUser.setCode(DateUtils.getsdfTimesSS());
|
||||
tbShopUser.setIsVip(Byte.parseByte("1"));
|
||||
}
|
||||
|
||||
|
||||
@@ -83,8 +83,6 @@ public class ProductService {
|
||||
tbShopUser.setShopId(shopId);
|
||||
tbShopUser.setUserId(userId);
|
||||
tbShopUser.setMiniOpenId(openId);
|
||||
tbShopUser.setPwd(MD5Util.encrypt("123456"));
|
||||
tbShopUser.setIsPwd("0");
|
||||
tbShopUser.setCreatedAt(System.currentTimeMillis());
|
||||
tbShopUser.setUpdatedAt(System.currentTimeMillis());
|
||||
tbShopUserMapper.insert(tbShopUser);
|
||||
|
||||
@@ -94,7 +94,6 @@ public class ThirdPayService {
|
||||
*/
|
||||
|
||||
public PublicResp<WxScanPayResp> scanpay(String url,String appId, String subject, String body, Long amount,String payType, String subAppId, String userId,
|
||||
|
||||
String clinetIp,String orderNo, String storeId, String notifyUrl,String returnUrl,
|
||||
String key){
|
||||
WxScanPayReq scanPayReq=new WxScanPayReq(subject,body,amount,"cny",payType,subAppId,userId,clinetIp,orderNo,storeId,notifyUrl,returnUrl);
|
||||
|
||||
@@ -116,7 +116,7 @@
|
||||
</update>
|
||||
|
||||
<select id="selectByAmount" resultMap="BaseResultMap">
|
||||
select * from tb_activate where shop_id=#{shopId} and is_del=0 and min_num <= #{amount} and max_num >={amount}
|
||||
select * from tb_activate where shop_id=#{shopId} and is_del=0 and min_num <= #{amount} and max_num >= #{amount}
|
||||
</select>
|
||||
|
||||
<select id="selectByShpopId" resultMap="BaseResultMap">
|
||||
|
||||
@@ -380,13 +380,30 @@
|
||||
select * from tb_shop_user where user_id=#{userId} and shop_id=#{shopId}
|
||||
</select>
|
||||
|
||||
<select id="selectByUserId" resultMap="BaseResultMap">
|
||||
select * from tb_shop_user where user_id=#{userId}
|
||||
</select>
|
||||
<select id="selectByOpenId" resultType="com.chaozhanggui.system.cashierservice.entity.TbShopUser">
|
||||
select * from tb_shop_user where mini_open_id = #{openId}
|
||||
</select>
|
||||
<select id="selectParams" resultType="com.chaozhanggui.system.cashierservice.entity.TbParams">
|
||||
select * from tb_params where id = 1
|
||||
</select>
|
||||
|
||||
<select id="selectByUserId" resultType="java.util.Map">
|
||||
SELECT
|
||||
i.id as shopId,
|
||||
i.shop_name as shopName,
|
||||
i.chain_name as chainName,
|
||||
i.logo,
|
||||
i.detail,
|
||||
u.amount,
|
||||
u.`code`,
|
||||
u.is_vip
|
||||
FROM
|
||||
tb_shop_user u
|
||||
left join tb_shop_info i on u.shop_id=i.id
|
||||
WHERE
|
||||
u.user_id = #{userId}
|
||||
<if test="shopId != null and shopId !=''">
|
||||
and shop_id = #{shopId}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user