添加员工折扣
This commit is contained in:
@@ -3,6 +3,7 @@ package com.chaozhanggui.system.cashierservice.controller;
|
|||||||
import com.chaozhanggui.system.cashierservice.annotation.LimitSubmit;
|
import com.chaozhanggui.system.cashierservice.annotation.LimitSubmit;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
|
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.dto.ReturnGroupOrderDto;
|
import com.chaozhanggui.system.cashierservice.entity.dto.ReturnGroupOrderDto;
|
||||||
|
import com.chaozhanggui.system.cashierservice.model.PaymentReq;
|
||||||
import com.chaozhanggui.system.cashierservice.service.PayService;
|
import com.chaozhanggui.system.cashierservice.service.PayService;
|
||||||
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||||
@@ -45,8 +46,6 @@ public class PayController {
|
|||||||
* @param token
|
* @param token
|
||||||
* @param loginName
|
* @param loginName
|
||||||
* @param clientType
|
* @param clientType
|
||||||
* @param orderId
|
|
||||||
* @param authCode
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping("scanpay")
|
@RequestMapping("scanpay")
|
||||||
@@ -55,13 +54,10 @@ public class PayController {
|
|||||||
@RequestHeader("token") String token,
|
@RequestHeader("token") String token,
|
||||||
@RequestHeader("loginName") String loginName,
|
@RequestHeader("loginName") String loginName,
|
||||||
@RequestHeader("clientType") String clientType,
|
@RequestHeader("clientType") String clientType,
|
||||||
@RequestParam("orderId") String orderId,
|
@RequestBody PaymentReq paymentReq
|
||||||
@RequestParam("payAmount") BigDecimal payAmount,
|
|
||||||
@RequestParam("discountAmount") BigDecimal discountAmount,
|
|
||||||
@RequestParam("authCode") String authCode
|
|
||||||
|
|
||||||
) {
|
) {
|
||||||
return payService.scanPay(orderId,authCode, IpUtil.getIpAddr(request),token,payAmount,discountAmount);
|
return payService.scanPay(paymentReq.getOrderId(),paymentReq.getAuthCode(), IpUtil.getIpAddr(request),token,paymentReq.getPayAmount(),paymentReq.getDiscountAmount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -70,23 +66,17 @@ public class PayController {
|
|||||||
* @param token
|
* @param token
|
||||||
* @param loginName
|
* @param loginName
|
||||||
* @param clientType
|
* @param clientType
|
||||||
* @param orderId
|
|
||||||
* @param memberId
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@GetMapping("accountPay")
|
@RequestMapping("accountPay")
|
||||||
@LimitSubmit(key = "accountPay:%s")
|
@LimitSubmit(key = "accountPay:%s")
|
||||||
public Result accountPay(@RequestHeader("token") String token,
|
public Result accountPay(@RequestHeader("token") String token,
|
||||||
@RequestHeader("loginName") String loginName,
|
@RequestHeader("loginName") String loginName,
|
||||||
@RequestHeader("clientType") String clientType,
|
@RequestHeader("clientType") String clientType,
|
||||||
@RequestParam("orderId") String orderId,
|
@RequestBody PaymentReq paymentReq
|
||||||
@RequestParam("memberId") String memberId,
|
|
||||||
@RequestParam("memberAccount") String memberAccount,
|
|
||||||
@RequestParam("payAmount") BigDecimal payAmount,
|
|
||||||
@RequestParam("discountAmount") BigDecimal discountAmount
|
|
||||||
){
|
){
|
||||||
return payService.accountPay(orderId,memberId,token,memberAccount,payAmount,discountAmount);
|
return payService.accountPay(paymentReq.getOrderId(),paymentReq.getMemberId(),token,paymentReq.getMemberAccount(),paymentReq.getPayAmount(),paymentReq.getDiscountAmount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -159,21 +149,16 @@ public class PayController {
|
|||||||
* @param token
|
* @param token
|
||||||
* @param loginName
|
* @param loginName
|
||||||
* @param clientType
|
* @param clientType
|
||||||
* @param orderId
|
|
||||||
* @param memberCode
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("memberScanPay")
|
@RequestMapping("memberScanPay")
|
||||||
@LimitSubmit(key = "memberScanPay:%s")
|
@LimitSubmit(key = "memberScanPay:%s")
|
||||||
public Result memberScanPay(@RequestHeader("token") String token,
|
public Result memberScanPay(@RequestHeader("token") String token,
|
||||||
@RequestHeader("loginName") String loginName,
|
@RequestHeader("loginName") String loginName,
|
||||||
@RequestHeader("clientType") String clientType,
|
@RequestHeader("clientType") String clientType,
|
||||||
@RequestParam("orderId") String orderId,
|
@RequestBody PaymentReq paymentReq
|
||||||
@RequestParam("memberCode") String memberCode,
|
|
||||||
@RequestParam("payAmount") BigDecimal payAmount,
|
|
||||||
@RequestParam("discountAmount") BigDecimal discountAmount
|
|
||||||
){
|
){
|
||||||
return payService.memberScanPay(orderId,memberCode,token,payAmount,discountAmount);
|
return payService.memberScanPay(paymentReq.getOrderId(),paymentReq.getMemberCode(),token,paymentReq.getPayAmount(),paymentReq.getDiscountAmount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -183,18 +168,15 @@ public class PayController {
|
|||||||
* @param token
|
* @param token
|
||||||
* @param loginName
|
* @param loginName
|
||||||
* @param clientType
|
* @param clientType
|
||||||
* @param orderId
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("cashPay")
|
@RequestMapping("cashPay")
|
||||||
@LimitSubmit(key = "cashPay:%s")
|
@LimitSubmit(key = "cashPay:%s")
|
||||||
public Result cashPay(@RequestHeader("token") String token,
|
public Result cashPay(@RequestHeader("token") String token,
|
||||||
@RequestHeader("loginName") String loginName,
|
@RequestHeader("loginName") String loginName,
|
||||||
@RequestHeader("clientType") String clientType,
|
@RequestHeader("clientType") String clientType,
|
||||||
@RequestParam("orderId") String orderId,
|
@RequestBody PaymentReq paymentReq){
|
||||||
@RequestParam("payAmount") BigDecimal payAmount,
|
return payService.cashPay(paymentReq.getOrderId(),token,paymentReq.getPayAmount(),paymentReq.getDiscountAmount());
|
||||||
@RequestParam("discountAmount") BigDecimal discountAmount){
|
|
||||||
return payService.cashPay(orderId,token,payAmount,discountAmount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -225,18 +207,15 @@ public class PayController {
|
|||||||
* @param token
|
* @param token
|
||||||
* @param loginName
|
* @param loginName
|
||||||
* @param clientType
|
* @param clientType
|
||||||
* @param orderId
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("bankPay")
|
@RequestMapping("bankPay")
|
||||||
@LimitSubmit(key = "bankPay:%s")
|
@LimitSubmit(key = "bankPay:%s")
|
||||||
public Result bankPay(@RequestHeader("token") String token,
|
public Result bankPay(@RequestHeader("token") String token,
|
||||||
@RequestHeader("loginName") String loginName,
|
@RequestHeader("loginName") String loginName,
|
||||||
@RequestHeader("clientType") String clientType,
|
@RequestHeader("clientType") String clientType,
|
||||||
@RequestParam("orderId") String orderId,
|
@RequestBody PaymentReq paymentReq){
|
||||||
@RequestParam("payAmount") BigDecimal payAmount,
|
return payService.bankPay(paymentReq.getOrderId(),token,paymentReq.getPayAmount(),paymentReq.getDiscountAmount());
|
||||||
@RequestParam("discountAmount") BigDecimal discountAmount){
|
|
||||||
return payService.bankPay(orderId,token);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -275,4 +254,16 @@ public class PayController {
|
|||||||
public Result testOrder( @RequestParam("orderId") String orderId){
|
public Result testOrder( @RequestParam("orderId") String orderId){
|
||||||
return Result.success(CodeEnum.SUCCESS);
|
return Result.success(CodeEnum.SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping("getOrderDiscount")
|
||||||
|
public Result getOrderDiscount(@RequestHeader("token") String token,
|
||||||
|
@RequestHeader("loginName") String loginName,
|
||||||
|
@RequestHeader("clientType") String clientType,
|
||||||
|
@RequestParam("orderId") String orderId,
|
||||||
|
@RequestParam("staffId") String staffId
|
||||||
|
){
|
||||||
|
return payService.getOrderDiscount(staffId, orderId, token);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.model;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class PaymentReq implements Serializable {
|
||||||
|
|
||||||
|
private String orderId;
|
||||||
|
|
||||||
|
private BigDecimal payAmount;
|
||||||
|
|
||||||
|
private BigDecimal discountAmount;
|
||||||
|
|
||||||
|
private String authCode;
|
||||||
|
|
||||||
|
private String memberId;
|
||||||
|
|
||||||
|
private String memberAccount;
|
||||||
|
|
||||||
|
private String memberCode;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1505,4 +1505,44 @@ public class PayService {
|
|||||||
tbGroupOrderInfoMapper.update(groupOrderInfo);
|
tbGroupOrderInfoMapper.update(groupOrderInfo);
|
||||||
return Result.success(CodeEnum.SUCCESS);
|
return Result.success(CodeEnum.SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Result getOrderDiscount(String staffId,String orderId,String token ){
|
||||||
|
if(ObjectUtil.isNull(staffId)||ObjectUtil.isNull(orderId)||ObjectUtil.isEmpty(staffId)||ObjectUtil.isEmpty(orderId)){
|
||||||
|
return Result.fail(CodeEnum.PARAM);
|
||||||
|
}
|
||||||
|
JSONObject tokeObj= TokenUtil.parseParamFromToken(token);
|
||||||
|
if(Objects.isNull(tokeObj)){
|
||||||
|
return Result.fail(CodeEnum.TOKENTERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!tokeObj.getString("staffId").equals(staffId)){
|
||||||
|
return Result.fail(CodeEnum.PARAM);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TbOrderInfo tbOrderInfo= tbOrderInfoMapper.selectByPrimaryKey(Integer.valueOf(orderId));
|
||||||
|
if(ObjectUtil.isNull(tokeObj)||ObjectUtil.isEmpty(tbOrderInfo)){
|
||||||
|
return Result.fail(CodeEnum.ORDERNOEXIST);
|
||||||
|
}
|
||||||
|
|
||||||
|
TbPlussShopStaff staff=tbPlussShopStaffMapper.selectByPrimaryKey(Integer.valueOf(staffId));
|
||||||
|
|
||||||
|
if(ObjectUtil.isEmpty(staff)||ObjectUtil.isNull(staff)){
|
||||||
|
return Result.fail(CodeEnum.STAFFNOEXISTERROE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ObjectUtil.isEmpty(staff.getMaxDiscountAmount())||ObjectUtil.isNull(staff.getMaxDiscountAmount())){
|
||||||
|
return Result.success(SUCCESS,BigDecimal.ZERO);
|
||||||
|
}
|
||||||
|
|
||||||
|
if("0".equals(staff.getDiscountType())){
|
||||||
|
staff.setMaxDiscountAmount(staff.getMaxDiscountAmount().divide(tbOrderInfo.getOrderAmount()).setScale(2,BigDecimal.ROUND_DOWN));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result.success(SUCCESS,staff.getMaxDiscountAmount());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user