java - 积分+金额购买商品,使用微信支付,什么时候扣减积分合适?
伊谢尔伦
伊谢尔伦 2017-04-17 17:17:08
0
5
649

我现在要做一个微信支付的功能,会员积分+金额的组合方式进行支付购买,请问各位大牛积分在什么时候进行抵扣比较好呢?

在支付成功的回调进行积分的减扣,如果这时积分余额不足怎么办?
发起微信支付预申请成功将积分扣除,如果用户取消支付,在回调处理时中断了怎么办?当然可以加上定时器扫描,一段时间内未完成支付操作的回滚积分

还有其他更好的办法吗?

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(5)
Ty80

Divided into two steps:
1. Generate an order
2. Pay for the order

It seems easy to understand the logic after breaking it down:

  1. Generate an order and associate it to generate two payment paths (points + WeChat)

  2. The order has a payment validity period (for example, automatic cancellation if payment is not made within 2 hours), and there is also an entry for manual cancellation by the user.

  3. Enter the payment logic after the order is generated. In these two logics, the points payment is carried out immediately, and the WeChat payment calls the interface. When the payment is successfully called back, the payment status of the two payment methods is checked. If both have been paid successfully, the order is paid successfully. If the points payment has not been completed, wait for the points payment. .

  4. If there is a timeout cancellation or the user cancels by himself, the payment from each path will be returned to the original route: the points will be returned to the points account, and WeChat will call the refund interface

刘奇

Judge the points before initiating payment and then deduct them after the payment is successful? Isn’t this okay?

洪涛

After initiating payment, freeze the points to be deducted. If the payment is successful, the points will be deducted. If the payment fails or is canceled, the points will be unfrozen.

大家讲道理

Set how many RMB a point will cost at the beginning, or launch a separate point + cash activity, otherwise it will be difficult to add it later.
I think you can add a new module and define the value of points yourself. Users can choose the number of points to use when making purchases, and they can be combined into cash for calculation during settlement.

洪涛

Points will be deducted first.
1. If the payment is unsuccessful, points will be returned according to the payment callback function and the order will be voided.
2. If the payment is successful, just modify the order status to completed.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!