收银台

This commit is contained in:
cun-nan 2023-11-23 18:37:40 +08:00
parent d68f87b29b
commit 302a7850fe
18 changed files with 849 additions and 205 deletions

View File

@ -36,4 +36,16 @@ public class FyPayController {
Map<String, String> map = payService.queryOrder(map1); Map<String, String> map = payService.queryOrder(map1);
return map; return map;
} }
/**
* 退款 成功 result_msg 显示success
* result_code显示000000
* @return
* @throws Exception
*/
@PostMapping("/refund")
public Map<String, String> refund(Map<String, String> map1) throws Exception {
Map<String, String> map = payService.refund(map1);
return map;
}
} }

View File

@ -52,7 +52,7 @@ public class Builder {
} }
/** /**
* 条码支付下单查询 * 条码支付下单 查询订单是否支付成功
* *
* @return * @return
*/ */
@ -71,4 +71,34 @@ public class Builder {
return map; return map;
} }
/**
* 退款
*
* @return
*/
public static Map<String, String> buildFuiou24() {
Map<String, String> map = new HashMap<>();
map.put("version", Const.version);
map.put("ins_cd", Const.ins_cd);
map.put("mchnt_cd", Const.mchnt_cd);
map.put("term_id", Const.term_id);
map.put("random_str", randomNumberGenerator.nextBytes().toHex());
map.put("sign", "");
map.put("order_type", Const.order_type);
map.put("mchnt_order_no", "");
// 商户退款单号
map.put("refund_order_no", "");
// 总金额
map.put("total_amt", "");
// 退款金额
map.put("refund_amt", "");
map.put("operator_id", "");
map.put("reserved_fy_term_id", "");
map.put("reserved_origi_dt", "");
map.put("reserved_addn_inf", "");
return map;
}
} }

View File

@ -16,4 +16,11 @@ public interface FyPayService {
* @throws Exception * @throws Exception
*/ */
public Map<String, String> queryOrder(Map<String, String> map) throws Exception; public Map<String, String> queryOrder(Map<String, String> map) throws Exception;
/**
* 退款
* @return
* @throws Exception
*/
public Map<String, String> refund(Map<String, String> map) throws Exception;
} }

View File

@ -11,16 +11,12 @@ import com.fuint.api.fuyou.service.FyPayService;
import com.fuint.api.fuyou.service.MerchantConfigService; import com.fuint.api.fuyou.service.MerchantConfigService;
import com.fuint.api.fuyou.util.Utils; import com.fuint.api.fuyou.util.Utils;
import com.fuint.business.integral.service.IntegralOrdersService; import com.fuint.business.integral.service.IntegralOrdersService;
import com.fuint.business.marketingActivity.cardFavorable.entity.CardFavorableRecord;
import com.fuint.business.marketingActivity.cardFavorable.service.CardFavorableRecordService;
import com.fuint.business.marketingActivity.cardFule.service.CardFuelRecordService; import com.fuint.business.marketingActivity.cardFule.service.CardFuelRecordService;
import com.fuint.business.marketingActivity.cardValue.service.CardValueRecordService; import com.fuint.business.marketingActivity.cardValue.service.CardValueRecordService;
import com.fuint.business.order.entity.CashierOrder; import com.fuint.business.order.entity.*;
import com.fuint.business.order.entity.HangBill; import com.fuint.business.order.service.*;
import com.fuint.business.order.entity.LJOrder;
import com.fuint.business.order.entity.OilOrder;
import com.fuint.business.order.service.CashierOrderService;
import com.fuint.business.order.service.HangBillService;
import com.fuint.business.order.service.LJOrderService;
import com.fuint.business.order.service.OilOrderService;
import com.fuint.common.dto.AccountInfo; import com.fuint.common.dto.AccountInfo;
import com.fuint.common.util.TokenUtil; import com.fuint.common.util.TokenUtil;
import io.swagger.models.auth.In; import io.swagger.models.auth.In;
@ -83,7 +79,6 @@ public class FyPayServiceImpl implements FyPayService {
String str = resMap.get("sign"); String str = resMap.get("sign");
if (Utils.verifySign(resMap, str)){ if (Utils.verifySign(resMap, str)){
String resultCode = resMap.get("result_code");
ThreadUtil.execAsync(() -> { ThreadUtil.execAsync(() -> {
Timer timer = new Timer(); Timer timer = new Timer();
timer.schedule(new TimerTask() { timer.schedule(new TimerTask() {
@ -110,6 +105,10 @@ public class FyPayServiceImpl implements FyPayService {
private MerchantConfigService merchantConfigService; private MerchantConfigService merchantConfigService;
@Autowired @Autowired
private HangBillService hangBillService; private HangBillService hangBillService;
@Autowired
private ReturnRecordService returnRecordService;
@Autowired
private CardFavorableRecordService cardFavorableRecordService;
@Override @Override
public Map<String, String> queryOrder(Map<String, String> map1) throws Exception { public Map<String, String> queryOrder(Map<String, String> map1) throws Exception {
@ -148,24 +147,43 @@ public class FyPayServiceImpl implements FyPayService {
LJOrder goodsOrder = goodsOrderService.selectGoodsOrder(orderNo); LJOrder goodsOrder = goodsOrderService.selectGoodsOrder(orderNo);
CashierOrder cashierOrder = cashierOrderService.selectCashierOrder(orderNo); CashierOrder cashierOrder = cashierOrderService.selectCashierOrder(orderNo);
MerchantConfig merchantConfig = merchantConfigService.selectMeChByIsUse("1"); MerchantConfig merchantConfig = merchantConfigService.selectMeChByIsUse("1");
HangBill hangBill = hangBillService.selectHangBillByOrderNo(orderNo); List<ReturnRecord> returnRecords = returnRecordService.selectReturnRecordByOrderNo(orderNo);
Date date = new Date(); Date date = new Date();
if (reqMap.get("trans_stat").equals("SUCCESS")){ if (reqMap.get("trans_stat").equals("SUCCESS")){
if (!ObjectUtil.isEmpty(oilOrder)){ if (!ObjectUtil.isEmpty(oilOrder)){
// 油品订单
oilOrder.setOrderStatus("paid"); oilOrder.setOrderStatus("paid");
oilOrder.setPayTime(date); oilOrder.setPayTime(date);
// 修改优惠券使用状态
CardFavorableRecord byId = cardFavorableRecordService.getById(oilOrder.getCouponId());
if (!ObjectUtil.isEmpty(byId)){
byId.setStatus("1");
cardFavorableRecordService.updateById(byId);
}
} }
if (!ObjectUtil.isEmpty(goodsOrder)){ if (!ObjectUtil.isEmpty(goodsOrder)){
// 商品订单
goodsOrder.setStatus("paid"); goodsOrder.setStatus("paid");
goodsOrder.setPayTime(date);
} }
if (!ObjectUtil.isEmpty(cashierOrder)){ if (!ObjectUtil.isEmpty(cashierOrder)){
// 收银台订单
cashierOrder.setStatus("paid"); cashierOrder.setStatus("paid");
cashierOrder.setPayTime(date);
} }
if (!ObjectUtil.isEmpty(hangBill)){ if (!ArrayUtil.isEmpty(returnRecords)){
hangBillService.updateHangBills(hangBill,allAmount,"paid"); for (ReturnRecord returnRecord : returnRecords) {
// 挂账归还信息
returnRecord.setReturnType("1");
returnRecord.setPayStatus("paid");
returnRecord.setPayTime(date);
hangBillService.updateHangBill(returnRecord.getHangBillId(), returnRecord.getAmount());
returnRecordService.updateReturnRecord(returnRecord);
}
} }
if (ArrayUtil.isEmpty(list)){ if (!ArrayUtil.isEmpty(list)){
for (OilOrder order : list) { for (OilOrder order : list) {
// 添加多个油品订单
order.setOrderStatus("paid"); order.setOrderStatus("paid");
order.setPayTime(date); order.setPayTime(date);
oilOrderService.updateOilOrder(order); oilOrderService.updateOilOrder(order);
@ -200,9 +218,12 @@ public class FyPayServiceImpl implements FyPayService {
if (!ObjectUtil.isEmpty(cashierOrder)){ if (!ObjectUtil.isEmpty(cashierOrder)){
cashierOrder.setStatus("payFail"); cashierOrder.setStatus("payFail");
} }
if (!ObjectUtil.isEmpty(hangBill)){ if (!ArrayUtil.isEmpty(returnRecords)){
hangBill.setPayStatus("payFail"); for (ReturnRecord returnRecord : returnRecords) {
hangBillService.updateById(hangBill); returnRecord.setReturnType("0");
returnRecord.setPayStatus("payFail");
returnRecordService.updateReturnRecord(returnRecord);
}
} }
if (!ArrayUtil.isEmpty(list)){ if (!ArrayUtil.isEmpty(list)){
for (OilOrder order : list) { for (OilOrder order : list) {
@ -254,4 +275,37 @@ public class FyPayServiceImpl implements FyPayService {
return resMap; return resMap;
} }
@Override
public Map<String, String> refund(Map<String, String> map1) throws Exception {
String orderNo = map1.get("orderNo");
String refundOrderNo = map1.get("refundOrderNo");
String payType = map1.get("payType");
String allAmount = map1.get("allAmount");
String insCd = map1.get("insCd");
String mchntCd = map1.get("mchntCd");
Map<String, String> map = Builder.buildFuiou24();
map.put("mchnt_order_no",orderNo);
map.put("order_type",payType);
map.put("total_amt", allAmount);
map.put("refund_amt", allAmount);
map.put("ins_cd", insCd);
map.put("mchnt_cd", mchntCd);
map.put("refund_order_no", refundOrderNo);
// 请求报文
String reqBody = Message.requestMsg(map);
// 响应报文
String rspXml = Message.responseMsg(reqBody,Const.fuiou_24_url);
//响应报文验签
Map<String, String> resMap = Utils.xmlStr2Map(rspXml);
String str = resMap.get("sign");
if (Utils.verifySign(resMap, str)){
}
return resMap;
}
} }

View File

@ -75,8 +75,7 @@ public class HangBillController extends BaseController {
*/ */
@PutMapping @PutMapping
public ResponseObject edit(@Validated @RequestBody Map<String,String> map){ public ResponseObject edit(@Validated @RequestBody Map<String,String> map){
HangBill hangBill = hangBillService.updateHangBill(map); return getSuccessResult(hangBillService.collection(map));
return getSuccessResult(hangBill);
} }
/** /**
@ -86,8 +85,7 @@ public class HangBillController extends BaseController {
*/ */
@PostMapping("/batch") @PostMapping("/batch")
public ResponseObject batchUpdate(@Validated @RequestBody Map<String,String> map){ public ResponseObject batchUpdate(@Validated @RequestBody Map<String,String> map){
int row = hangBillService.batchUpdate(map); return getSuccessResult(hangBillService.batchUpdate(map));
return getSuccessResult(row);
} }
/** /**

View File

@ -0,0 +1,60 @@
package com.fuint.business.order.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fuint.business.order.service.ReturnRecordService;
import com.fuint.business.order.vo.ReturnRecordVo;
import com.fuint.framework.web.BaseController;
import com.fuint.framework.web.ResponseObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* 归还记录信息 controller层
*/
@RestController
@RequestMapping("/business/returnRecord")
public class ReturnRecordController extends BaseController {
@Autowired
private ReturnRecordService returnRecordService;
/**
* 根据挂账记录id查询归还记录信息
* @param returnRecordVo
* @param pageNo
* @param pageSize
* @return
*/
@GetMapping("/list")
public ResponseObject list(ReturnRecordVo returnRecordVo,
@RequestParam(value = "page",defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize){
Page page =new Page(pageNo,pageSize);
IPage<ReturnRecordVo> returnRecordVoIPage = returnRecordService.selectReturnRecordList(page, returnRecordVo);
return getSuccessResult(returnRecordVoIPage);
}
/**
* 根据id查询挂账归还信息
* @param id
* @return
*/
@GetMapping("/{id}")
public ResponseObject info(@PathVariable Integer id){
return getSuccessResult(returnRecordService.selectReturnRecordById(id));
}
/**
* 根据订单号查询挂账归还信息
* @param map
* @return
*/
@PostMapping("/order")
public ResponseObject infoByOrderNo(@Validated @RequestBody Map<String,String> map){
String orderNo = map.get("orderNo");
return getSuccessResult(returnRecordService.selectReturnRecordByOrderNo(orderNo));
}
}

View File

@ -54,6 +54,10 @@ public class CashierOrder extends BaseEntity implements Serializable {
* 订单号 * 订单号
*/ */
private String orderNo; private String orderNo;
/**
* 退款订单号
*/
private String refundOrderNo;
/** /**
* 油品订单金额 * 油品订单金额
*/ */

View File

@ -0,0 +1,82 @@
package com.fuint.business.order.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fuint.framework.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.io.Serializable;
/**
* 归还记录表(ReturnRecord)实体类
*/
@Data
@TableName("return_record")
@ApiModel(value = "ReturnRecord对象", description = "归还记录表")
public class ReturnRecord extends BaseEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@ApiModelProperty("自增ID")
@TableId(value = "ID", type = IdType.AUTO)
private Integer id;
/**
* 挂账记录id
*/
private Integer hangBillId;
/**
* 店铺id
*/
private Integer storeId;
/**
* 订单号
*/
private String orderNo;
/**
* 挂账单位id
*/
private Integer creditUnitId;
/**
* 订单状态0未归还1已归还
*/
private String status;
/**
* 归还状态0挂账1归还
*/
private String returnType;
/**
* 挂账金额
*/
private Double amount;
/**
* 收款金额
*/
private Double collectAmount;
/**
* 找零金额
*/
private Double seekZero;
/**
* 操作员工id
*/
private Integer staffId;
/**
* 单据备注
*/
private String remark;
/**
* 支付状态已支付未支付支付失败
*/
private String payStatus;
/**
* 支付时间
*/
private Date payTime;
}

View File

@ -0,0 +1,21 @@
package com.fuint.business.order.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fuint.business.order.entity.ReturnRecord;
import com.fuint.business.order.vo.ReturnRecordVo;
import org.apache.ibatis.annotations.Param;
/**
* 挂账归还记录表 mapper层
*/
public interface ReturnRecordMapper extends BaseMapper<ReturnRecord> {
/**
* 根据挂账记录id查询归还信息
* @param page
* @param returnRecord
* @return
*/
public IPage<ReturnRecordVo> selectReturnRecordList(Page page, @Param("returnRecord") ReturnRecordVo returnRecord);
}

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.fuint.business.order.mapper.ReturnRecordMapper">
<sql id="selectReturnRecord">
select rd.*,ms.real_name,ms.mobile,cu.unit_name,cu.person_credit,cu.contact_mobile,cu.credit_limit
from return_record rd
left join credit_unit cu on cu.id = rd.credit_unit_id
left join mt_staff ms on rd.staff_id = ms.id
</sql>
<select id="selectReturnRecordList" resultType="com.fuint.business.order.vo.ReturnRecordVo">
<include refid="selectReturnRecord"></include>
<where>
rd.hang_bill_id = #{returnRecord.hangBillId}
</where>
</select>
<!-- <select id="selectHangBillById" resultType="com.fuint.business.order.vo.HangBillVo" parameterType="int">-->
<!-- <include refid="selectHangBill"></include>-->
<!-- <where>-->
<!-- hb.id = #{id}-->
<!-- </where>-->
<!-- </select>-->
<!-- <select id="selectHangBills" resultType="com.fuint.business.order.vo.HangBillVo" parameterType="int">-->
<!-- <include refid="selectHangBill"></include>-->
<!-- <where>-->
<!-- hb.store_id = #{storeId}-->
<!-- </where>-->
<!-- </select>-->
</mapper>

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.fuint.business.order.entity.HangBill; import com.fuint.business.order.entity.HangBill;
import com.fuint.business.order.entity.ReturnRecord;
import com.fuint.business.order.vo.HangBillVo; import com.fuint.business.order.vo.HangBillVo;
import java.util.List; import java.util.List;
@ -49,18 +50,26 @@ public interface HangBillService extends IService<HangBill> {
public int insertHangBill(HangBillVo hangBill); public int insertHangBill(HangBillVo hangBill);
/** /**
* 修改挂账记录 并收款 * 修改挂账记录信息
* @param id
* @param amount
* @return
*/
public int updateHangBill(int id,Double amount);
/**
* 添加归还信息并收款
* @param map * @param map
* @return * @return
*/ */
public HangBill updateHangBill(Map<String,String> map); public String collection(Map<String,String> map);
/** /**
* 批量归还挂账金额 * 批量归还挂账金额
* @param map * @param map
* @return * @return
*/ */
public int batchUpdate(Map<String,String> map); public String batchUpdate(Map<String,String> map);
/** /**
* 修改挂账信息 * 修改挂账信息

View File

@ -0,0 +1,50 @@
package com.fuint.business.order.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.fuint.business.order.entity.ReturnRecord;
import com.fuint.business.order.vo.ReturnRecordVo;
import java.util.List;
/**
* 挂账归还记录表 业务层
*/
public interface ReturnRecordService extends IService<ReturnRecord> {
/**
* 根据挂账记录id查询归还信息
* @param page
* @param returnRecord
* @return
*/
public IPage<ReturnRecordVo> selectReturnRecordList(Page page,ReturnRecordVo returnRecord);
/**
* 根据id查询归还记录信息
* @param id
* @return
*/
public ReturnRecord selectReturnRecordById(int id);
/**
* 根据订单号查询归还记录信息
* @param orderNo
* @return
*/
public List<ReturnRecord> selectReturnRecordByOrderNo(String orderNo);
/**
* 添加挂账归还信息 并返回订单号
* @param returnRecord
* @return
*/
public String insertReturnRecord(ReturnRecord returnRecord);
/**
* 修改挂账归还信息
* @param returnRecord
* @return
*/
public int updateReturnRecord(ReturnRecord returnRecord);
}

View File

@ -13,9 +13,11 @@ import com.fuint.api.fuyou.service.MerchantConfigService;
import com.fuint.api.fuyou.service.OilConfigService; import com.fuint.api.fuyou.service.OilConfigService;
import com.fuint.business.order.entity.CreditUnit; import com.fuint.business.order.entity.CreditUnit;
import com.fuint.business.order.entity.HangBill; import com.fuint.business.order.entity.HangBill;
import com.fuint.business.order.entity.ReturnRecord;
import com.fuint.business.order.mapper.HangBillMapper; import com.fuint.business.order.mapper.HangBillMapper;
import com.fuint.business.order.service.CreditUnitService; import com.fuint.business.order.service.CreditUnitService;
import com.fuint.business.order.service.HangBillService; import com.fuint.business.order.service.HangBillService;
import com.fuint.business.order.service.ReturnRecordService;
import com.fuint.business.order.vo.HangBillVo; import com.fuint.business.order.vo.HangBillVo;
import com.fuint.common.dto.AccountInfo; import com.fuint.common.dto.AccountInfo;
import com.fuint.common.util.TokenUtil; import com.fuint.common.util.TokenUtil;
@ -114,72 +116,109 @@ public class HangBillServiceImpl extends ServiceImpl<HangBillMapper, HangBill> i
private OilConfigService oilConfigService; private OilConfigService oilConfigService;
@Override @Override
public HangBill updateHangBill(Map<String,String> map) { public int updateHangBill(int id,Double amount) {
HangBill hangBill1 = this.selectHangBillByOrderNo(map.get("orderNo")); HangBill hangBill = baseMapper.selectById(id);
hangBill1.setPayStatus("unpaid"); Double repaidAmount = hangBill.getRepaidAmount();
baseMapper.updateById(hangBill1); Double outstandAmount = hangBill.getOutstandAmount();
String payType = map.get("payType"); // 修改变化金额
// 调用支付接口 Double repaidAmountAfter = repaidAmount+amount;
this.pay(map); Double outstandAmountAfter = outstandAmount-amount;
hangBill.setRepaidAmount(repaidAmountAfter);
// 根据id查询挂账信息 hangBill.setOutstandAmount(outstandAmountAfter);
HangBill hangBill = baseMapper.selectById(Integer.parseInt(map.get("id"))); // 修改状态
if (payType.equals("CASH")){ if (repaidAmountAfter.equals(hangBill.getAmount()) && outstandAmountAfter.equals(0.0)){
hangBill.setStatus("1");
hangBill.setReturnType("1");
hangBill.setPayStatus("paid"); hangBill.setPayStatus("paid");
}else {
hangBill.setStatus("2");
} }
// 根据挂账单位id查询挂账单位信息 // 根据挂账单位id查询挂账单位信息
CreditUnit creditUnit = creditUnitService.selectCreditUnitListById(hangBill.getCreditUnitId()); CreditUnit creditUnit = creditUnitService.selectCreditUnitListById(hangBill.getCreditUnitId());
if (creditUnit.getCreditLimit()!=0){ // 挂账单位限额的数据添加
Double creditLimit = creditUnit.getCreditLimit(); Double creditLimit = creditUnit.getCreditLimit();
creditUnit.setCreditLimit(creditLimit+Double.valueOf(map.get("repaidAmount"))); if (creditLimit!=0) {
} creditUnit.setCreditLimit(creditLimit+amount);
int row = 0;
hangBill.setRemark(map.get("remark"));
// 支付成功后修改挂账信息
if (hangBill.getPayStatus().equals("paid")){
Double repaidAmount1 = Double.valueOf(map.get("repaidAmount"));
Double amount = hangBill.getAmount();
Double repaidAmount = hangBill.getRepaidAmount();
Double outstandAmount = hangBill.getOutstandAmount();
Double repaidAmountAfter = repaidAmount+repaidAmount1;
// 修改挂账信息
hangBill.setRepaidAmount(repaidAmountAfter);
hangBill.setOutstandAmount(amount-repaidAmountAfter);
if (amount.equals(repaidAmountAfter)){
hangBill.setStatus("1");
hangBill.setReturnType("1");
}else {
hangBill.setStatus("2");
}
// 修改挂账单位余额信息
creditUnitService.updateCreditUnit(creditUnit); creditUnitService.updateCreditUnit(creditUnit);
} }
row = baseMapper.updateById(hangBill); int row = baseMapper.updateById(hangBill);
return baseMapper.selectById(Integer.parseInt(map.get("id"))); return row;
}
@Autowired
private ReturnRecordService returnRecordService;
@Override
public String collection(Map<String, String> map) {
// 添加归还账单信息
ReturnRecord returnRecord = new ReturnRecord();
returnRecord.setHangBillId(Integer.valueOf(map.get("id")));
returnRecord.setStoreId(Integer.valueOf(map.get("storeId")));
returnRecord.setCreditUnitId(Integer.valueOf(map.get("creditUnitId")));
returnRecord.setStaffId(Integer.valueOf(map.get("staffId")));
returnRecord.setStatus(map.get("payType"));
returnRecord.setRemark(map.get("remark"));
returnRecord.setAmount(Double.valueOf(map.get("repaidAmount")));
if (map.get("payType").equals("CASH")){
returnRecord.setCollectAmount(Double.valueOf(map.get("authCode")));
returnRecord.setSeekZero(Double.valueOf(map.get("seekZero")));
returnRecord.setPayStatus("paid");
returnRecord.setReturnType("1");
returnRecord.setPayTime(new Date());
Double amount = Double.valueOf(map.get("authCode")) - Double.valueOf(map.get("seekZero"));
this.updateHangBill(returnRecord.getHangBillId(), amount);
}else {
returnRecord.setCollectAmount(Double.valueOf(map.get("repaidAmount")));
returnRecord.setReturnType("0");
returnRecord.setPayStatus("unpaid");
}
String orderNo = returnRecordService.insertReturnRecord(returnRecord);
// 调用支付接口
this.pay(map,orderNo);
return orderNo;
} }
@Override @Override
public int batchUpdate(Map<String, String> map) { public String batchUpdate(Map<String, String> map) {
this.pay(map);
List<JSONObject> jsonObjects = JSONArray.parseArray(map.get("list"), JSONObject.class); List<JSONObject> jsonObjects = JSONArray.parseArray(map.get("list"), JSONObject.class);
int row = 0; // 根据日期生成归还订单号
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
String timestamp = dateFormat.format(new Date());
String randomString = UUID.randomUUID().toString().replace("-","").substring(0,6);
String orderNo = "H"+timestamp+randomString;
for (JSONObject jsonObject : jsonObjects) { for (JSONObject jsonObject : jsonObjects) {
// 现将需要修改的支付状态改为未支付 // 添加归还记录信息
HangBill hangBill1 = baseMapper.selectById((Integer) jsonObject.get("id")); ReturnRecord returnRecord = new ReturnRecord();
returnRecord.setOrderNo(orderNo);
hangBill1.setPayStatus("unpaid"); returnRecord.setHangBillId((Integer) jsonObject.get("id"));
baseMapper.updateById(hangBill1); returnRecord.setStoreId((Integer) jsonObject.get("storeId"));
HangBill hangBill = baseMapper.selectById((Integer) jsonObject.get("id")); returnRecord.setCreditUnitId((Integer) jsonObject.get("creditUnitId"));
returnRecord.setStaffId((Integer) jsonObject.get("staffId"));
returnRecord.setStatus(map.get("payType"));
returnRecord.setRemark((String) jsonObject.get("remark"));
returnRecord.setAmount(Double.valueOf(jsonObject.get("repaidAmount").toString()));
if (map.get("payType").equals("CASH")){ if (map.get("payType").equals("CASH")){
HangBill hangBill2 = this.updateStatus(hangBill, Double.valueOf(jsonObject.get("repaidAmount").toString())); returnRecord.setCollectAmount(Double.valueOf(map.get("authCode")));
hangBill2.setPayStatus("paid"); returnRecord.setSeekZero(Double.valueOf(map.get("seekZero")));
hangBill2.setRemark(map.get("remark")); returnRecord.setPayStatus("paid");
row = baseMapper.updateById(hangBill2); returnRecord.setReturnType("1");
returnRecord.setPayTime(new Date());
Double amount = Double.valueOf(jsonObject.get("repaidAmount").toString());
this.updateHangBill(returnRecord.getHangBillId(), amount);
}else {
returnRecord.setCollectAmount(Double.valueOf(jsonObject.get("repaidAmount").toString()));
returnRecord.setReturnType("0");
returnRecord.setPayStatus("unpaid");
} }
returnRecordService.insertReturnRecord(returnRecord);
} }
return row; // 调用支付接口
this.pay(map,orderNo);
return orderNo;
} }
@Override @Override
@ -194,7 +233,8 @@ public class HangBillServiceImpl extends ServiceImpl<HangBillMapper, HangBill> i
* 调用支付接口 * 调用支付接口
* @param map * @param map
*/ */
private void pay(Map<String,String> map){ private void pay(Map<String,String> map,String orderNo){
// 先将支付状态改为未支付
String payType = map.get("payType"); String payType = map.get("payType");
if (!map.get("repaidAmount").equals("0") && !payType.equals("CASH")){ if (!map.get("repaidAmount").equals("0") && !payType.equals("CASH")){
Integer allAmount = (int) (Double.valueOf(map.get("repaidAmount"))*100); Integer allAmount = (int) (Double.valueOf(map.get("repaidAmount"))*100);
@ -209,7 +249,7 @@ public class HangBillServiceImpl extends ServiceImpl<HangBillMapper, HangBill> i
Map<String,String> map1 = new HashMap<>(); Map<String,String> map1 = new HashMap<>();
map1.put("authCode",map.get("authCode")); map1.put("authCode",map.get("authCode"));
map1.put("allAmount",allAmount.toString()); map1.put("allAmount",allAmount.toString());
map1.put("orderNo",map.get("orderNo")); map1.put("orderNo",orderNo);
map1.put("payType",payType); map1.put("payType",payType);
map1.put("insCd",merchantConfig.getInsCd()); map1.put("insCd",merchantConfig.getInsCd());
map1.put("mchntCd",merchantConfig.getMchntCd()); map1.put("mchntCd",merchantConfig.getMchntCd());

View File

@ -0,0 +1,60 @@
package com.fuint.business.order.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fuint.business.order.entity.ReturnRecord;
import com.fuint.business.order.mapper.ReturnRecordMapper;
import com.fuint.business.order.service.ReturnRecordService;
import com.fuint.business.order.vo.ReturnRecordVo;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.UUID;
/**
* 挂账归还记录表 业务层
*/
@Service
public class ReturnRecordServiceImpl extends ServiceImpl<ReturnRecordMapper, ReturnRecord> implements ReturnRecordService {
@Override
public IPage<ReturnRecordVo> selectReturnRecordList(Page page, ReturnRecordVo returnRecord) {
return baseMapper.selectReturnRecordList(page,returnRecord);
}
@Override
public ReturnRecord selectReturnRecordById(int id) {
return baseMapper.selectById(id);
}
@Override
public List<ReturnRecord> selectReturnRecordByOrderNo(String orderNo) {
QueryWrapper queryWrapper = new QueryWrapper<>();
queryWrapper.eq("order_no",orderNo);
List<ReturnRecord> list = baseMapper.selectList(queryWrapper);
return list;
}
@Override
public String insertReturnRecord(ReturnRecord returnRecord) {
if (StrUtil.isEmpty(returnRecord.getOrderNo())){
// 根据日期生成归还订单号
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
String timestamp = dateFormat.format(new Date());
String randomString = UUID.randomUUID().toString().replace("-","").substring(0,6);
String orderNo = "H"+timestamp+randomString;
returnRecord.setOrderNo(orderNo);
}
baseMapper.insert(returnRecord);
return returnRecord.getOrderNo();
}
@Override
public int updateReturnRecord(ReturnRecord returnRecord) {
return baseMapper.updateById(returnRecord);
}
}

View File

@ -0,0 +1,20 @@
package com.fuint.business.order.vo;
import com.fuint.business.order.entity.ReturnRecord;
import lombok.Data;
@Data
public class ReturnRecordVo extends ReturnRecord {
// 操作人名称
private String realName;
// 操作人手机号
private String mobile;
// 单位名称
private String unitName;
// 挂账人
private String personCredit;
// 联系电话
private String contactMobile;
// 挂账额度
private String creditLimit;
}

View File

@ -0,0 +1,27 @@
import request from '@/utils/request'
// 根据挂账记录id查询归还记录信息
export function listReturnRecord(query) {
return request({
url: '/business/returnRecord/list',
method: 'get',
params: query
})
}
// 根据id查询挂账归还信息
export function returnRecordInfo(id) {
return request({
url: '/business/returnRecord/' + id,
method: 'get',
})
}
// 根据订单号查询挂账归还信息
export function returnRecordByOrderNo(data) {
return request({
url: '/business/returnRecord/order',
method: 'post',
data: data
})
}

View File

@ -139,69 +139,35 @@
</el-form> </el-form>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column prop="orderNo" label="单据号" width="200"></el-table-column>
prop="orderNo"
label="单据号"
width="200">
</el-table-column>
<el-table-column label="挂账单位"> <el-table-column label="挂账单位">
<el-table-column <el-table-column prop="unitName" label="单位名称"> </el-table-column>
prop="unitName" <el-table-column prop="personCredit" label="挂账人"> </el-table-column>
label="单位名称"> <el-table-column prop="contactMobile" label="联系电话"> </el-table-column>
</el-table-column>
<el-table-column
prop="personCredit"
label="挂账人">
</el-table-column>
<el-table-column
prop="contactMobile"
label="联系电话">
</el-table-column>
</el-table-column> </el-table-column>
<el-table-column label="记录明细"> <el-table-column label="记录明细">
<el-table-column <el-table-column prop="returnType" label="类型">
prop="returnType"
label="类型">
<template slot-scope="scope"> <template slot-scope="scope">
<el-tag v-if="scope.row.returnType == 0">挂账</el-tag> <el-tag v-if="scope.row.returnType == 0">挂账</el-tag>
<el-tag v-else type="success">归还</el-tag> <el-tag v-else type="success">归还</el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column prop="amount" label="金额"> </el-table-column>
prop="amount" <el-table-column prop="status" label="状态">
label="金额">
</el-table-column>
<el-table-column
prop="status"
label="状态">
<template slot-scope="scope"> <template slot-scope="scope">
<span v-if="scope.row.status == 0">未归还</span> <span v-if="scope.row.status == 0">未归还</span>
<span v-else-if="scope.row.status == 1" type="success">已归还</span> <span v-else-if="scope.row.status == 1" type="success">已归还</span>
<span v-else type="success">部分归还</span> <span v-else type="success">部分归还</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column prop="outstandAmount" label="未归还金额"> </el-table-column>
prop="outstandAmount"
label="未归还金额">
</el-table-column>
</el-table-column> </el-table-column>
<el-table-column <el-table-column prop="realName" label="操作人"> </el-table-column>
prop="realName" <el-table-column prop="createTime" label="创建时间" width="220">
label="操作人">
</el-table-column>
<el-table-column
prop="createTime"
label="创建时间"
width="220">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span> <span>{{ parseTime(scope.row.createTime) }}</span>
</template> </template>
</el-table-column> </el-table-column>
<!-- <el-table-column-->
<!-- prop="zip"-->
<!-- label="操作"-->
<!-- width="220">-->
<!-- </el-table-column>-->
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<!-- <el-button--> <!-- <el-button-->
@ -209,17 +175,17 @@
<!-- type="text"--> <!-- type="text"-->
<!-- icon="el-icon-edit"--> <!-- icon="el-icon-edit"-->
<!-- >修改</el-button>--> <!-- >修改</el-button>-->
<!-- <el-button-->
<!-- size="mini"-->
<!-- type="text"-->
<!-- icon="el-icon-delete"-->
<!-- >删除</el-button>-->
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
:disabled="scope.row.status == 1" :disabled="scope.row.status == 1"
@click="repay(scope.row.id)" @click="repay(scope.row.id)"
>归还</el-button> >归还</el-button>
<el-button
size="mini"
type="text"
@click="returnRecord(scope.row.id)"
>归还详情</el-button>
</template> </template>
</el-table-column> </el-table-column>
@ -238,6 +204,90 @@
</div> </div>
</el-card> </el-card>
<!-- 归还记录信息-->
<el-drawer
title="归还详情"
:visible.sync="drawer"
direction="rtl"
size="55%"
:before-close="handleClose">
<div style="display: grid; place-items: center;">
<el-card style="background-color: #f5f5f5;width: 90%">
<div slot="header" class="clearfix">
<div style="position: relative;">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);">
<h2>单据号{{record.orderNo}}</h2>
</div>
</div>
<br>
<div style="display: flex; justify-content: space-between;">
<span>操作员工</span>
<span>{{ record.realName }}</span>
</div>
</div>
<div >
<div style="display: flex; justify-content: space-between;">
<span>挂账单位</span>
<span>{{record.unitName}}</span>
</div>
<div style="display: flex; justify-content: space-between;margin: 10px 0">
<span>挂账人</span>
<span>{{record.personCredit}}</span>
</div>
<div style="display: flex; justify-content: space-between;">
<span>联系电话</span>
<span>{{record.contactMobile}}</span>
</div>
</div>
</el-card>
<el-card style="margin-top: 15px;width: 90%">
<el-table ref="tables"
v-loading="loading"
:data="returnRecordList">
<el-table-column label="单据号" align="center" prop="orderNo" width="200"></el-table-column>
<el-table-column label="类型" align="center" prop="returnType">
<template slot-scope="scope">
<el-tag v-if="scope.row.returnType == 0">挂账</el-tag>
<el-tag v-else type="success">归还</el-tag>
</template>
</el-table-column>
<el-table-column label="归还金额" align="center" prop="amount" />
<el-table-column label="找零金额" align="center" prop="seekZero" />
<el-table-column label="归还方式" align="center" prop="status">
<template slot-scope="scope">
<span>{{ getPayMeth(payList,scope.row.status) }}</span>
</template>
</el-table-column>
<el-table-column label="支付状态" align="center" prop="payStatus">
<template slot-scope="scope">
<el-tag v-if="scope.row.payStatus == 'unpaid'">未支付</el-tag>
<el-tag type="success" v-else-if="scope.row.payStatus == 'paid'">已支付</el-tag>
<el-tag type="danger" v-else>支付失败</el-tag>
</template>
</el-table-column>
<el-table-column label="操作人" align="center" prop="realName" />
<el-table-column label="支付时间" align="center" prop="payTime" width="200">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.payTime) }}</span>
</template>
</el-table-column>
</el-table>
<div class="pagination-box">
<el-pagination
background
layout="prev, pager, next"
v-show="total2>0"
:total="total2"
:page.sync="queryParams1.page"
:limit.sync="queryParams1.pageSize"
@current-change="getRecordList">
</el-pagination>
</div>
</el-card>
</div>
</el-drawer>
<!-- 新增挂账记录--> <!-- 新增挂账记录-->
<el-dialog title="新增挂账记录" :visible.sync="open" width="700px" append-to-body> <el-dialog title="新增挂账记录" :visible.sync="open" width="700px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="120px"> <el-form ref="form" :model="form" :rules="rules" label-width="120px">
@ -620,6 +670,7 @@ import {
} from "@/api/cashier/hangbill"; } from "@/api/cashier/hangbill";
import {addCreditUnit, listCreditUnit} from "@/api/cashier/creditunit"; import {addCreditUnit, listCreditUnit} from "@/api/cashier/creditunit";
import {getDicts} from "@/api/dict/data"; import {getDicts} from "@/api/dict/data";
import {listReturnRecord, returnRecordByOrderNo, returnRecordInfo} from "@/api/cashier/returnrecord";
export default { export default {
name: "credit", name: "credit",
@ -643,6 +694,7 @@ import {getDicts} from "@/api/dict/data";
isPay:true, isPay:true,
isPaySuccess:false, isPaySuccess:false,
loading: false, loading: false,
drawer: false,
// //
title:'', title:'',
// //
@ -664,6 +716,8 @@ import {getDicts} from "@/api/dict/data";
form2:{payType:"WECHAT"}, form2:{payType:"WECHAT"},
form3:{}, form3:{},
form4:{payType:"WECHAT"}, form4:{payType:"WECHAT"},
//
record:{},
// //
queryParams: { queryParams: {
page: 1, page: 1,
@ -673,13 +727,21 @@ import {getDicts} from "@/api/dict/data";
page: 1, page: 1,
pageSize: 10, pageSize: 10,
}, },
queryParams1: {
page: 1,
pageSize: 10,
hangBillId:"",
},
// //
dateRange: [], dateRange: [],
// //
hangBillList:[], hangBillList:[],
//
returnRecordList:[],
// //
total: 0, total: 0,
total1: 0, total1: 0,
total2: 0,
// //
open:false, open:false,
open1:false, open1:false,
@ -693,6 +755,7 @@ import {getDicts} from "@/api/dict/data";
isBatch:false, isBatch:false,
timer:"", timer:"",
unitName:"", unitName:"",
orderNo:"",
// //
rules: { rules: {
unitName: [ { required: true, message: "请选择挂账单位", trigger: "blur" }, ], unitName: [ { required: true, message: "请选择挂账单位", trigger: "blur" }, ],
@ -769,6 +832,42 @@ import {getDicts} from "@/api/dict/data";
this.getLists(); this.getLists();
}, },
methods:{ methods:{
getPayMeth(list,val){
let name = "";
if (list!=null && list!=""){
list.forEach(item => {
if (item.dictValue == val){
name = item.dictLabel
}
})
}
return name;
},
//
handleClose(done) {
done();
},
//
returnRecord(id){
this.record = {}
this.drawer = true
hangBillInfo(id).then(response => {
this.record = response.data
})
this.getRecordList(id,1);
},
getRecordList(id,val){
if (val!=1){
this.queryParams1.page = id
this.queryParams1.hangBillId = this.record.id
}else {
this.queryParams1.hangBillId = id
}
listReturnRecord(this.queryParams1).then(response => {
this.returnRecordList = response.data.records
this.total2 = response.data.total
})
},
changePayType(val){ changePayType(val){
this.payType = val this.payType = val
}, },
@ -778,17 +877,19 @@ import {getDicts} from "@/api/dict/data";
}, },
// //
changeSeekZero(){ changeSeekZero(){
this.seekZero = this.authCode - this.oilActualPay - this.goodsActualPay this.seekZero = (this.authCode - this.payAmount).toFixed(2)
}, },
batchSub(){ batchSub(){
this.form4.list = JSON.stringify(this.tableList); this.form4.list = JSON.stringify(this.tableList);
this.form4.repaidAmount = this.repaidAmount; this.form4.repaidAmount = this.repaidAmount;
this.form4.payType = "WECHAT"
this.open4 = true; this.open4 = true;
}, },
batchReturn(){ batchReturn(){
this.open3 = true this.open3 = true
this.repayList = []; this.repayList = [];
this.unitName = "" this.unitName = ""
this.getLists();
}, },
getRepayList(){ getRepayList(){
let result = []; let result = [];
@ -854,37 +955,48 @@ import {getDicts} from "@/api/dict/data";
this.getList(); this.getList();
}, },
// //
collection(){ collection(val){
if (this.payType=="CASH"){
if (this.authCode==undefined || this.authCode=="" || this.seekZero<0){
this.$modal.msgError("请输入正确的金额变化");
return;
}
}
let _this = this; let _this = this;
if (this.isBatch){ if (this.isBatch){
// //
_this.form4.repaidAmount = _this.payAmount; _this.form4.repaidAmount = _this.payAmount;
_this.form4.authCode = _this.authCode; _this.form4.authCode = _this.authCode;
_this.form4.orderNo = _this.tableList[0].orderNo; _this.form4.seekZero = _this.seekZero
batchHangBill(_this.form4).then(response => { batchHangBill(_this.form4).then(response => {
if (response.data!=0){ //
_this.isPaySuccess = true; _this.orderNo = response.data
_this.isPay = false;
this.getList();
}
}) })
_this.loading = true; _this.loading = true;
_this.queryPayStatus();
let timer = setInterval(function () {
if (_this.isQuery == false) {
_this.loading = false;
_this.isPay = false;
clearInterval(_this.timer);
}
},1000)
setTimeout(function (){
_this.loading = false;
clearInterval(timer);
},30000)
this.open3 = false; this.open3 = false;
this.open4 = false; this.open4 = false;
this.getLists();
this.getList();
}else { }else {
// //
_this.form2.repaidAmount = _this.payAmount; _this.form2.repaidAmount = _this.payAmount;
_this.form2.authCode = _this.authCode; _this.form2.authCode = _this.authCode;
_this.form2.seekZero = _this.seekZero
editHangBill(this.form2).then(response => { editHangBill(this.form2).then(response => {
console.log(response) //
if (response.data==null){ _this.orderNo = response.data
}else {
if (response.data.payStatus == 'paid'){
_this.isPaySuccess = true;
_this.isPay = false;
}
}
}) })
_this.loading = true; _this.loading = true;
_this.queryPayStatus(); _this.queryPayStatus();
@ -907,20 +1019,22 @@ import {getDicts} from "@/api/dict/data";
queryPayStatus(){ queryPayStatus(){
let _this = this; let _this = this;
_this.timer = setInterval(function (){ _this.timer = setInterval(function (){
queryHangBill({orderNo:_this.form2.orderNo}).then(response => { returnRecordByOrderNo({orderNo:_this.orderNo}).then(response => {
if (response.data.payStatus == "unpaid"){ response.data.forEach(item => {
_this.isQuery = true; if (item.payStatus == "unpaid"){
} _this.isQuery = true;
if (response.data.payStatus == "paid"){ }
_this.isPaySuccess = true; if (item.payStatus == "paid"){
_this.isQuery = false; _this.isPaySuccess = true;
} _this.isQuery = false;
if (response.data.payStatus == "payFail"){ }
_this.isPaySuccess = false; if (item.payStatus == "payFail"){
_this.isQuery = false; _this.isPaySuccess = false;
} _this.isQuery = false;
}
})
}) })
},1000) },1001)
}, },
submitReturn(){ submitReturn(){
this.isPay = true; this.isPay = true;
@ -937,8 +1051,10 @@ import {getDicts} from "@/api/dict/data";
submitReturn1(){ submitReturn1(){
this.isPay = true; this.isPay = true;
this.isBatch = true; this.isBatch = true;
this.loading = false;
this.payAmount = this.form4.repaidAmount; this.payAmount = this.form4.repaidAmount;
this.authCode = this.form4.authCode; this.authCode = "";
// this.authCode = this.form4.authCode;
if (this.form4.payType!="CASH"){ if (this.form4.payType!="CASH"){
this.title = "扫码付款"; this.title = "扫码付款";
}else { }else {
@ -954,6 +1070,7 @@ import {getDicts} from "@/api/dict/data";
}, },
// //
repay(id){ repay(id){
this.payType = "WECHAT"
hangBillInfo(id).then( response => { hangBillInfo(id).then( response => {
this.open2 = true; this.open2 = true;
this.form2 = response.data this.form2 = response.data
@ -1047,7 +1164,10 @@ import {getDicts} from "@/api/dict/data";
}) })
}, },
// //
getList(){ getList(val){
if (val!=undefined){
this.queryParams.page = val
}
listHangBill(this.addDateRange(this.queryParams, this.dateRange)).then( response => { listHangBill(this.addDateRange(this.queryParams, this.dateRange)).then( response => {
this.hangBillList = response.data.records this.hangBillList = response.data.records
this.total = response.data.total; this.total = response.data.total;

View File

@ -152,8 +152,20 @@
width="400" width="400"
trigger="click"> trigger="click">
<div> <div>
<el-checkbox-group v-model="checkedCities5" @change="handleCheckedCitiesChange5"> <!-- <el-checkbox-group v-model="checkedCities5" @change="handleCheckedCitiesChange5">-->
<el-checkbox v-for="(item,index) in couponDiscount" :label="item.name" :key="index"> <!-- <el-checkbox v-for="(item,index) in couponDiscount" :label="item.name" :key="index">-->
<!-- <div style="display: flex;justify-content: space-between;height: 40px;line-height: 40px;">-->
<!-- <div style="width: 200px">{{item.name}}</div>-->
<!-- <div style="line-height: 20px;width:150px;font-size: 12px;text-align: right">-->
<!-- <div style="color: red">-{{ item.reduce }}</div>-->
<!-- <div style="color: grey">{{ item.full }}{{ item.reduce }}</div>-->
<!-- </div>-->
<!-- </div>-->
<!-- </el-checkbox>-->
<!-- </el-checkbox-group>-->
<el-radio-group v-model="checkedCities5" @input="handleCheckedCitiesChange5">
<el-radio v-for="(item,index) in couponDiscount"
:label="item.name" :key="index" style="display: flex;">
<div style="display: flex;justify-content: space-between;height: 40px;line-height: 40px;"> <div style="display: flex;justify-content: space-between;height: 40px;line-height: 40px;">
<div style="width: 200px">{{item.name}}</div> <div style="width: 200px">{{item.name}}</div>
<div style="line-height: 20px;width:150px;font-size: 12px;text-align: right"> <div style="line-height: 20px;width:150px;font-size: 12px;text-align: right">
@ -161,8 +173,8 @@
<div style="color: grey">{{ item.full }}{{ item.reduce }}</div> <div style="color: grey">{{ item.full }}{{ item.reduce }}</div>
</div> </div>
</div> </div>
</el-checkbox> </el-radio>
</el-checkbox-group> </el-radio-group>
</div> </div>
<div slot="reference"> <div slot="reference">
<el-checkbox <el-checkbox
@ -808,7 +820,7 @@
// //
checkAll5: false, checkAll5: false,
isIndeterminate5: true, isIndeterminate5: true,
checkedCities5: [], checkedCities5: "",
cities5: cityOptions, cities5: cityOptions,
couponDiscount: [], couponDiscount: [],
// //
@ -939,6 +951,10 @@
isMember: false, isMember: false,
// //
staff:"", staff:"",
// id
couponIds:[],
// 使id
useCouponIds:[],
map:{ map:{
allAmount:0, allAmount:0,
// //
@ -1271,48 +1287,53 @@
this.checkAll1 = false; this.checkAll1 = false;
this.fullReduction = 0; this.fullReduction = 0;
this.isUseFull = true; this.isUseFull = true;
this.checkedCities5 = this.couponDiscount[0].name;
}else { }else {
this.isUseFull = false; this.isUseFull = false;
this.checkedCities5 = ""
} }
}else if (this.exclusion == 0){ }else if (this.exclusion == 0){
if (val){ if (val){
this.checkAll4 = false; this.checkAll4 = false;
this.consumeAmount = 0; this.consumeAmount = 0;
this.isUseBalance = true; this.isUseBalance = true;
this.checkedCities5 = this.couponDiscount[0].name;
}else { }else {
this.isUseBalance = false; this.isUseBalance = false;
this.checkedCities5 = ""
} }
} }
let list = []
this.couponDiscount.forEach(item => {
list.push(item.name)
})
if (val){ if (val){
this.couponAmount = 0 this.couponAmount = 0
this.couponDiscount.forEach(item2 => { this.couponAmount = this.couponDiscount[0].reduce
this.couponAmount += item2.reduce this.useCouponIds = ""
this.couponIds.forEach(item => {
if (item.name = this.couponDiscount[0].name){
this.useCouponIds = item.id
}
}) })
this.checkedCities5 = this.couponDiscount[0].name;
}else { }else {
this.useCouponIds = ""
this.couponAmount = 0 this.couponAmount = 0
this.checkedCities5 = ""
} }
this.checkedCities5 = val ? list : [];
this.isIndeterminate5 = false;
this.isExclusion(); this.isExclusion();
}, },
handleCheckedCitiesChange5(value) { handleCheckedCitiesChange5(value) {
this.couponAmount = 0; this.couponAmount = 0;
this.couponDiscount.forEach(item => { this.couponDiscount.forEach(item => {
let reduces = 0 if (item.name == value){
for (let i = 0; i < value.length; i++){ this.couponAmount = item.reduce
if (item.name == value[i]){
reduces = item.reduce
}
} }
this.couponAmount += reduces
}) })
let checkedCount = value.length; this.useCouponIds = ""
this.checkAll5 = checkedCount === this.couponDiscount.length; this.couponIds.forEach(item => {
this.isIndeterminate5 = checkedCount > 0 && checkedCount < this.couponDiscount.length; if (item.name == value){
this.useCouponIds = item.id
}
})
this.checkAll5 = true;
this.isExclusion(); this.isExclusion();
}, },
// //
@ -1646,10 +1667,13 @@
_this.preferentialData.oilPrice = item1.oilPrice; _this.preferentialData.oilPrice = item1.oilPrice;
_this.preferentialData.oilLiters = item1.liters; _this.preferentialData.oilLiters = item1.liters;
_this.couponDiscount =[]; _this.couponDiscount =[];
_this.couponIds = [],
selectCoupon(_this.preferentialData).then(response => { selectCoupon(_this.preferentialData).then(response => {
_this.couponAmount = 0; _this.couponAmount = 0;
_this.couponIds = response.data
if (response.data.length>0){ if (response.data.length>0){
response.data.forEach(item => { response.data.forEach(item => {
_this.useCouponIds.push(item.id)
let discount = {type:item.type,discountType:item.discountType,name:item.name,oilName:item1.oilName,full:0,reduce:0,discount:0} let discount = {type:item.type,discountType:item.discountType,name:item.name,oilName:item1.oilName,full:0,reduce:0,discount:0}
discount.full = item.satisfiedAmount discount.full = item.satisfiedAmount
if (item.type==0){ if (item.type==0){
@ -1688,12 +1712,19 @@
_this.couponDiscount.forEach(item2 => { _this.couponDiscount.forEach(item2 => {
if (item2.oilName!=discount.oilName) { if (item2.oilName!=discount.oilName) {
_this.couponDiscount.push(discount) _this.couponDiscount.push(discount)
_this.checkedCities5.push(item.name) _this.checkedCities5 = item.name
_this.couponAmount = discount.reduce
}
if (item2.name!=discount.name && item2.oilName==discount.oilName) {
_this.couponDiscount.push(discount)
_this.checkedCities5 = item.name
_this.couponAmount = discount.reduce
} }
}) })
}else { }else {
_this.couponDiscount.push(discount) _this.couponDiscount.push(discount)
_this.checkedCities5.push(item.name) _this.checkedCities5 = item.name
_this.couponAmount = discount.reduce
} }
} }
if (item.exclusiveFunction == 0){ if (item.exclusiveFunction == 0){
@ -1712,12 +1743,7 @@
_this.exclusion = item.exclusiveFunction _this.exclusion = item.exclusiveFunction
}) })
} }
let couponAmount = 0; _this.checkAll5 = true;
_this.couponDiscount.forEach(item2 => {
couponAmount += item2.reduce
_this.checkAll5 = true;
})
_this.couponAmount = couponAmount
_this.isExclusion(); _this.isExclusion();
}) })
}) })
@ -1763,6 +1789,11 @@
// //
isExclusion(){ isExclusion(){
if (this.exclusion == 1){ if (this.exclusion == 1){
// 使
if (this.isUseBalance){
this.countAmountFull()
return;
}
// //
if (this.isUseBalance){ if (this.isUseBalance){
this.countAmountUnBalance() this.countAmountUnBalance()
@ -1773,6 +1804,11 @@
} }
}else if (this.exclusion == 0){ }else if (this.exclusion == 0){
// //
// 使
if (this.isUseBalance){
this.countAmountUnBalance()
return;
}
if (this.isUseFull){ if (this.isUseFull){
this.countAmountFull() this.countAmountFull()
return; return;
@ -1848,17 +1884,6 @@
_this.fullReduction = 0 _this.fullReduction = 0
} }
_this.isExclusion(); _this.isExclusion();
// if (_this.isUseFull){
// _this.checkAll1 = false;
// _this.fullReduction = 0;
// _this.checkedCities1 = []
// _this.countAmountFull()
// return;
// }else {
// _this.countAmountBalance()
// return;
// }
// _this.oilActualPay = oilActualPay - _this.oilDiscount - _this.fullReduction - _this.balance
}) })
}) })
}, },
@ -1994,11 +2019,6 @@
this.oilAmount += +item.amount this.oilAmount += +item.amount
}) })
// if (this.select == ""){
// this.oilAmount = +this.form.amount + this.oilAmount;
// }else {
// this.oilAmount = this.form.amount + this.oilAmount;
// }
this.oilActualPay = this.oilAmount - this.oilDiscount; this.oilActualPay = this.oilAmount - this.oilDiscount;
this.oilTotal = this.oilOrder.length; this.oilTotal = this.oilOrder.length;
this.select = "元"; this.select = "元";
@ -2174,6 +2194,7 @@
this.map.consumeAmount = this.consumeAmount; this.map.consumeAmount = this.consumeAmount;
this.updateRefuelMoney(); this.updateRefuelMoney();
this.map.refuelMoney = JSON.stringify(this.refuelMoney) this.map.refuelMoney = JSON.stringify(this.refuelMoney)
this.map.couponId = this.useCouponIds
let _this = this; let _this = this;
addLJGoods(_this.map).then( response => { addLJGoods(_this.map).then( response => {