pay.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package service
  2. import (
  3. "encoding/json"
  4. . "bp.jydev.jianyu360.cn/BaseService/orderCenter/entity"
  5. "bp.jydev.jianyu360.cn/BaseService/orderCenter/rpc/ordercenter"
  6. )
  7. func PayAdd(this *ordercenter.PayAddReq) *ordercenter.OrderAddUpdateResp {
  8. payId := Mysql.Insert(Pay, map[string]interface{}{
  9. "appid": this.Appid,
  10. "order_code": this.OrderCode,
  11. "pay_time": this.Pay.PayTime,
  12. "pay_way": this.Pay.PayWay,
  13. "pay_money": this.Pay.PayMoney,
  14. "pay_code": this.Pay.PayCode,
  15. "pay_voucher_url": this.Pay.PayVoucherUrl,
  16. "pay_account": this.Pay.PayAccount,
  17. "pay_name": this.Pay.PayName,
  18. "collect_account": this.Pay.CollectAccount,
  19. "collect_name": this.Pay.CollectName,
  20. "operate_person": this.Pay.OperatePerson,
  21. "operate_time": this.Pay.OperateTime,
  22. "remark": this.Pay.Remark,
  23. "prepay_time": this.Pay.PrepayTime,
  24. "prepay_id": this.Pay.PrepayId,
  25. "out_trade_no": this.Pay.OutTradeNo,
  26. "code_url": this.Pay.CodeUrl,
  27. "origin_price": this.Pay.OriginPrice,
  28. "points_deduct_count": this.Pay.PointsDeductCount,
  29. "points_deduct_amount": this.Pay.PointsDeductAmount,
  30. "card_count": this.Pay.CardCount,
  31. "card_amount": this.Pay.CardAmount,
  32. })
  33. status := 0
  34. if payId > 0 {
  35. status = 1
  36. }
  37. return &ordercenter.OrderAddUpdateResp{
  38. ErrorCode: 1,
  39. Data: &ordercenter.DataStatus{Status: int64(status)},
  40. }
  41. }
  42. func PayInfo(this *ordercenter.OrderInfoReq) *ordercenter.PayInfoResp {
  43. PayList := []*ordercenter.Pay{}
  44. pay := Mysql.Find(Pay, map[string]interface{}{"appid": this.Appid, "order_code": this.OrderCode}, "", "", 0, 0)
  45. if pay != nil && len(*pay) > 0 {
  46. for _, v := range *pay {
  47. payData := &ordercenter.Pay{}
  48. payByte, _ := json.Marshal(v)
  49. json.Unmarshal(payByte, payData)
  50. PayList = append(PayList, payData)
  51. }
  52. }
  53. return &ordercenter.PayInfoResp{
  54. ErrorCode: 1,
  55. Data: PayList,
  56. }
  57. }