Selaa lähdekoodia

add 单笔微信转账给用户

master
dengbiao 4 kuukautta sitten
vanhempi
commit
0a0b014d27
9 muutettua tiedostoa jossa 325 lisäystä ja 2 poistoa
  1. +134
    -0
      app/admin/hdl/enterprise_manage/hdl_central_kitchen_for_school.go
  2. +19
    -0
      app/admin/md/md_enterprise.go
  3. +16
    -0
      app/admin/md/md_enterprise_manage.go
  4. +99
    -0
      app/db/db_central_kitchen_wx_transfer_ord.go
  5. +24
    -0
      app/db/db_central_kitchen_wx_transfer_ord_list.go
  6. +15
    -0
      app/db/model/central_kitchen_wx_transfer_ord.go
  7. +13
    -0
      app/db/model/central_kitchen_wx_transfer_ord_list.go
  8. +3
    -0
      app/router/admin_router.go
  9. +2
    -2
      cmd_db.bat

+ 134
- 0
app/admin/hdl/enterprise_manage/hdl_central_kitchen_for_school.go Näytä tiedosto

@@ -1650,3 +1650,137 @@ func CentralKitchenForSchoolClassDeleteCheck(c *gin.Context) {
}, nil)
return
}

func CentralKitchenForSchoolWxTransferOrdList(c *gin.Context) {
var req md.CentralKitchenForSchoolWxTransferOrdListReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}

centralKitchenWxTransferOrdDb := db.CentralKitchenWxTransferOrd{}
centralKitchenWxTransferOrdDb.Set("")
list, total, err := centralKitchenWxTransferOrdDb.FindCentralKitchenWxTransferOrd(req.Phone, req.Page, req.Limit)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}

e.OutSuc(c, map[string]interface{}{
"list": list,
"total": total,
"state_list": md.CentralKitchenWxTransferOrdForState,
}, nil)
return
}

func CentralKitchenForSchoolWxTransfer(c *gin.Context) {
var req md.CentralKitchenForSchoolWxTransferReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}

uDb := db.UserDb{}
uDb.Set()
outTradeNo := utils.OrderUUID(int(time.Now().Unix()))
sysCfgDb := db.SysCfgDb{}
sysCfgDb.Set()
sysCfg := sysCfgDb.SysCfgFindWithDb(enum.WxAppletAppId)
appid := sysCfg[enum.WxAppletAppId]
now := time.Now()
var centralKitchenWxTransferOrdData *model.CentralKitchenWxTransferOrd
var centralKitchenWxTransferOrdListData []*model.CentralKitchenWxTransferOrdList
var totalAmount float64
for key, uid := range req.Uids {
user, err := uDb.GetUser(uid)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
if user == nil {
e.OutErr(c, e.ERR_NOT_FAN, "未查询到相关用户")
return
}
if user.OpenId == "" {
e.OutErr(c, e.ERR_NOT_FAN, "当前用户openid为空")
return
}
totalAmount += utils.StrToFloat64(req.Amount)
centralKitchenWxTransferOrdListData = append(centralKitchenWxTransferOrdListData, &model.CentralKitchenWxTransferOrdList{
Uid: user.Id,
OutTradeNo: outTradeNo,
OutDetailNo: outTradeNo + "_" + utils.IntToStr(key),
TransferRemark: "智盛-央厨转账",
TransferAmount: req.Amount,
Openid: user.OpenId,
CreateAt: now.Format("2006-01-02 15:04:05"),
UpdateAt: now.Format("2006-01-02 15:04:05"),
})
}
if totalAmount > 200 {
e.OutErr(c, e.ERR, "总计转账金额超过200元上限")
return
}

centralKitchenWxTransferOrdData = &model.CentralKitchenWxTransferOrd{
Appid: appid,
OutTradeNo: outTradeNo,
BatchName: "智盛-央厨转账",
BatchRemark: req.BatchRemark,
TotalAmount: req.Amount,
TotalNum: len(req.Uids),
State: 1,
Msg: "",
CreateAt: now.Format("2006-01-02 15:04:05"),
UpdateAt: now.Format("2006-01-02 15:04:05"),
}

session := db.Db.NewSession()
defer session.Close()
session.Begin()

centralKitchenWxTransferOrdDb := db.CentralKitchenWxTransferOrd{}
centralKitchenWxTransferOrdDb.Set("")
_, err = centralKitchenWxTransferOrdDb.CentralKitchenWxTransferOrdInsertBySession(session, centralKitchenWxTransferOrdData)
if err != nil {
session.Rollback()
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

centralKitchenWxTransferOrdListDb := db.CentralKitchenWxTransferOrdList{}
centralKitchenWxTransferOrdListDb.Set("")
_, err = centralKitchenWxTransferOrdListDb.BatchAddCentralKitchenWxTransferOrdListBySession(session, centralKitchenWxTransferOrdListData)
if err != nil {
session.Rollback()
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

e.OutSuc(c, "success", nil)
return
}

func CentralKitchenForSchoolWxTransferOrdFlow(c *gin.Context) {
outTradeNo := c.DefaultQuery("out_trade_no", "")

centralKitchenWxTransferOrdDb := db.CentralKitchenWxTransferOrd{OutTradeNo: outTradeNo}
resp, err := centralKitchenWxTransferOrdDb.GetCentralKitchenWxTransferOrd()
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}

e.OutSuc(c, map[string]interface{}{
"data": resp,
"state_list": md.CentralKitchenWxTransferOrdForState,
}, nil)
return
}

+ 19
- 0
app/admin/md/md_enterprise.go Näytä tiedosto

@@ -179,3 +179,22 @@ var EnterpriseKindForSchool = []map[string]interface{}{
"value": enum.EnterpriseKindBySelfSupportForSchool,
},
}

var CentralKitchenWxTransferOrdForState = []map[string]interface{}{
{
"name": "已受理",
"value": 1,
},
{
"name": "转账中",
"value": 2,
},
{
"name": "已完成",
"value": 3,
},
{
"name": "已关闭",
"value": 4,
},
}

+ 16
- 0
app/admin/md/md_enterprise_manage.go Näytä tiedosto

@@ -781,3 +781,19 @@ type SaveNursingHomePackageReq struct {
IsOpenReplenish int32 `json:"is_open_replenish"`
} `json:"date_list" binding:"required" label:"日期"`
}

type CentralKitchenForSchoolWxTransferOrdListReq struct {
Phone string `json:"phone" label:"家长联系电话"`
Limit int `json:"limit" binding:"required"`
Page int `json:"page" binding:"required"`
StartAmount string `json:"start_amount" `
EndAmount string `json:"end_amount" `
StartDate string `json:"start_date" label:"开始时间"`
EndDate string `json:"end_date" label:"截止时间"`
}

type CentralKitchenForSchoolWxTransferReq struct {
Uids []int `json:"uids" binding:"required"`
Amount string `json:"amount" `
BatchRemark string `json:"batch_remark" `
}

+ 99
- 0
app/db/db_central_kitchen_wx_transfer_ord.go Näytä tiedosto

@@ -0,0 +1,99 @@
package db

import (
"applet/app/db/model"
"applet/app/utils/logx"
"errors"
"xorm.io/xorm"
)

type CentralKitchenWxTransferOrd struct {
Db *xorm.Engine `json:"db"`
OutTradeNo string `json:"out_trade_no"`
}

func (centralKitchenWxTransferOrdDb *CentralKitchenWxTransferOrd) Set(outTradeNo string) { // set方法
centralKitchenWxTransferOrdDb.Db = Db
centralKitchenWxTransferOrdDb.OutTradeNo = outTradeNo
}

type GetCentralKitchenWxTransferOrdResp struct {
Ord *model.CentralKitchenWxTransferOrd `json:"ord"`
List *[]model.CentralKitchenWxTransferOrdList `json:"list"`
}

func (centralKitchenWxTransferOrdDb *CentralKitchenWxTransferOrd) GetCentralKitchenWxTransferOrd() (resp GetCentralKitchenWxTransferOrdResp, err error) {
//1、查找 central_kitchen_wx_transfer_ord
m := new(model.CentralKitchenWxTransferOrd)
has, err := centralKitchenWxTransferOrdDb.Db.Where("out_trade_no =?", centralKitchenWxTransferOrdDb.OutTradeNo).Get(m)
if err != nil {
return resp, logx.Error(err)
}
if has == false {
return resp, errors.New("未查询到相关转账记录")
}
resp.Ord = m

//1、查找 central_kitchen_wx_transfer_ord_list 记录
var list *[]model.CentralKitchenWxTransferOrdList
err = centralKitchenWxTransferOrdDb.Db.Where("out_trade_no =?", centralKitchenWxTransferOrdDb.OutTradeNo).Find(&list)
if err != nil {
return resp, err
}
resp.List = list
return
}

func (centralKitchenWxTransferOrdDb *CentralKitchenWxTransferOrd) FindCentralKitchenWxTransferOrd(phone string, page, limit int) (list []*FindCentralKitchenWxTransferOrd, total int64, err error) {
sess := centralKitchenWxTransferOrdDb.Db.
Join("LEFT", "user", "user.id = central_kitchen_wx_transfer_ord.uid")
if phone != "" {
sess.And("user.phone like ?", "%"+phone+"%")
}
total, err = sess.Limit(limit, (page-1)*limit).FindAndCount(&list)
if err != nil {
return nil, 0, err
}
return
}

func (centralKitchenWxTransferOrdDb *CentralKitchenWxTransferOrd) CentralKitchenWxTransferOrdInsert(m *model.CentralKitchenWxTransferOrd) (int, error) {
_, err := centralKitchenWxTransferOrdDb.Db.InsertOne(m)
if err != nil {
return 0, err
}
return m.Id, nil
}

func (centralKitchenWxTransferOrdDb *CentralKitchenWxTransferOrd) CentralKitchenWxTransferOrdInsertBySession(session *xorm.Session, m *model.CentralKitchenWxTransferOrd) (int, error) {
_, err := session.InsertOne(m)
if err != nil {
return 0, err
}
return m.Id, nil
}

func (centralKitchenWxTransferOrdDb *CentralKitchenWxTransferOrd) CentralKitchenWxTransferOrdUpdate(m *model.CentralKitchenWxTransferOrd, forceColums ...string) (int64, error) {
var (
affected int64
err error
)
if forceColums != nil {
affected, err = centralKitchenWxTransferOrdDb.Db.Where("out_trade_no=?", centralKitchenWxTransferOrdDb.OutTradeNo).Cols(forceColums...).Update(m)
} else {
affected, err = centralKitchenWxTransferOrdDb.Db.Where("out_trade_no=?", centralKitchenWxTransferOrdDb.OutTradeNo).Update(m)
}
if err != nil {
return 0, err
}
return affected, nil
}

type FindCentralKitchenWxTransferOrd struct {
model.CentralKitchenWxTransferOrd `xorm:"extends"`
model.User `xorm:"extends"`
}

func (FindCentralKitchenWxTransferOrd) TableName() string {
return "central_kitchen_wx_transfer_ord"
}

+ 24
- 0
app/db/db_central_kitchen_wx_transfer_ord_list.go Näytä tiedosto

@@ -0,0 +1,24 @@
package db

import (
"applet/app/db/model"
"xorm.io/xorm"
)

type CentralKitchenWxTransferOrdList struct {
Db *xorm.Engine `json:"db"`
OutTradeNo string `json:"out_trade_no"`
}

func (centralKitchenWxTransferOrdListDb *CentralKitchenWxTransferOrdList) Set(outTradeNo string) { // set方法
centralKitchenWxTransferOrdListDb.Db = Db
centralKitchenWxTransferOrdListDb.OutTradeNo = outTradeNo
}

func (centralKitchenWxTransferOrdListDb *CentralKitchenWxTransferOrdList) BatchAddCentralKitchenWxTransferOrdListBySession(session *xorm.Session, mm []*model.CentralKitchenWxTransferOrdList) (int64, error) {
affected, err := session.Insert(mm)
if err != nil {
return 0, err
}
return affected, nil
}

+ 15
- 0
app/db/model/central_kitchen_wx_transfer_ord.go Näytä tiedosto

@@ -0,0 +1,15 @@
package model

type CentralKitchenWxTransferOrd struct {
Id int `json:"id" xorm:"not null pk autoincr INT"`
Appid string `json:"appid" xorm:"not null default '' comment('商户appid') CHAR(50)"`
OutTradeNo string `json:"out_trade_no" xorm:"not null default '' comment('商家批次单号') CHAR(50)"`
BatchName string `json:"batch_name" xorm:"not null default '' comment('批次名称') CHAR(50)"`
BatchRemark string `json:"batch_remark" xorm:"not null default '' comment('批次备注') CHAR(50)"`
TotalAmount string `json:"total_amount" xorm:"not null default 0.00 comment('转账总金额') DECIMAL(6,2)"`
TotalNum int `json:"total_num" xorm:"not null default 0 comment('转账总笔数') TINYINT"`
State int `json:"state" xorm:"not null default 1 comment('状态(1:已受理 2:转账中 3:已完成 4:已关闭)') TINYINT(1)"`
Msg string `json:"msg" xorm:"not null comment('具体原因') TEXT"`
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
}

+ 13
- 0
app/db/model/central_kitchen_wx_transfer_ord_list.go Näytä tiedosto

@@ -0,0 +1,13 @@
package model

type CentralKitchenWxTransferOrdList struct {
Id int `json:"id" xorm:"not null pk autoincr INT"`
Uid int `json:"uid" xorm:"not null default 0 comment('uid') INT"`
OutTradeNo string `json:"out_trade_no" xorm:"not null default '' comment('商家批次单号') CHAR(50)"`
OutDetailNo string `json:"out_detail_no" xorm:"not null default '' comment('商家明细单号') CHAR(50)"`
TransferRemark string `json:"transfer_remark" xorm:"not null default '' comment('转账备注') CHAR(50)"`
TransferAmount string `json:"transfer_amount" xorm:"not null default 0.00 comment('转账金额') DECIMAL(6,2)"`
Openid string `json:"openid" xorm:"not null default '' comment('收款用户openid') CHAR(50)"`
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
}

+ 3
- 0
app/router/admin_router.go Näytä tiedosto

@@ -110,6 +110,9 @@ func rFinanceManage(r *gin.RouterGroup) {
r.POST("/nursingHome/ordList", hdl.NursingHomeOrdList) //财务管理-(养老院)订单列表
r.GET("/nursingHome/ordDetail", hdl.NursingHomeOrdDetail) //财务管理-(养老院)订单详情
r.POST("/nursingHome/ordRefund", hdl.NursingHomeOrdRefund) //财务管理-(养老院)订单退款
r.POST("/centralKitchenForSchool/wxTransferOrdList", hdl.CentralKitchenForSchoolWxTransferOrdList) //财务管理-(央厨-学校)订单转账列表
r.GET("/centralKitchenForSchool/wxTransferOrdFlow", hdl.CentralKitchenForSchoolWxTransferOrdFlow) //财务管理-(央厨-学校)订单转账明细
r.POST("/centralKitchenForSchool/wxTransfer", hdl.CentralKitchenForSchoolWxTransfer) //财务管理-(央厨-学校)订单转账
}

func rDeviceManage(r *gin.RouterGroup) {


+ 2
- 2
cmd_db.bat Näytä tiedosto

@@ -11,9 +11,9 @@ if "%one%" NEQ "" (

set BasePath="./"
set DBUSER="root"
set DBPSW="Fnuo123com@"
set DBPSW="ZhiSheng123.com"
set DBNAME="smart_canteen"
set DBHOST="119.23.182.117"
set DBHOST="39.108.126.122"
set DBPORT="3306"

del "app\db\model\%Table%.go"


Ladataan…
Peruuta
Tallenna