Commit 034d2450 authored by Peter Cheng's avatar Peter Cheng

1.追加萬事達金流API

2.修正早退時間計算錯誤問題
parent bea71d3a
...@@ -169,3 +169,25 @@ go get -u -v github.com/gin-gonic/gin ...@@ -169,3 +169,25 @@ go get -u -v github.com/gin-gonic/gin
//HTTP Header需設定成Content-Type: application/json //HTTP Header需設定成Content-Type: application/json
{} {}
``` ```
重新設定所有員工休假區間 http://[Your Host Name]:8806/GoMyPay/PayCreditCard
```
//HTTP Header需設定成Content-Type: application/json
{
"Send_Type":"1",
"Pay_Mode_No":"2",
"Order_No":"2019062500001",
"Amount":"100",
"TransCode":"00",
"Buyer_Name":"Peter Cheng",
"Buyer_Mail":"teed7334@gmail.com",
"Buyer_Memo":"Omega 手錶",
"CardNo":"5509158011124600",
"ExpireDate":"2307",
"CVV":"811",
"TransMode":"1",
"Installment":"0",
"e_return":"1",
"Str_Check":""
}
```
\ No newline at end of file
package base
import (
"bytes"
"io/ioutil"
"log"
"net/http"
)
//GetURL 透過HTTP GET取得網頁資料
func GetURL(url string) []byte {
request, err := http.NewRequest("GET", url, nil)
if err != nil {
panic(err)
}
client := &http.Client{}
result, err := client.Do(request)
if err != nil {
panic(err)
}
body, _ := ioutil.ReadAll(result.Body)
defer result.Body.Close()
return body
}
//PostURL 透過HTTP POST扔資料給特定網頁
func PostURL(url string, params []byte) []byte {
request, err := http.NewRequest("POST", url, bytes.NewBuffer(params))
request.Header.Set("X-Custom-Header", "counter")
request.Header.Set("Content-Type", "application/json")
client := &http.Client{}
result, err := client.Do(request)
if err != nil {
log.Panic(err)
}
body, _ := ioutil.ReadAll(result.Body)
defer result.Body.Close()
return body
}
// Code generated by protoc-gen-go.
// source: gomypay.proto
// DO NOT EDIT!
/*
Package beans is a generated protocol buffer package.
It is generated from these files:
gomypay.proto
punchclock.proto
redis.proto
sendMail.proto
It has these top-level messages:
CreditCard
Punchclock
TimeStruct
Redis
SendMail
*/
package beans
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
type CreditCard struct {
SendType string `protobuf:"bytes,1,opt,name=SendType" json:"Send_Type,omitempty"`
PayModeNo string `protobuf:"bytes,2,opt,name=PayModeNo" json:"Pay_Mode_No,omitempty"`
CustomerId string `protobuf:"bytes,3,opt,name=CustomerId" json:"CustomerId,omitempty"`
OrderNo string `protobuf:"bytes,4,opt,name=OrderNo" json:"Order_No,omitempty"`
Amount string `protobuf:"bytes,5,opt,name=Amount" json:"Amount,omitempty"`
TransCode string `protobuf:"bytes,6,opt,name=TransCode" json:"TransCode,omitempty"`
BuyerName string `protobuf:"bytes,7,opt,name=BuyerName" json:"Buyer_Name,omitempty"`
BuyerTelm string `protobuf:"bytes,8,opt,name=BuyerTelm" json:"Buyer_Telm,omitempty"`
BuyerMail string `protobuf:"bytes,9,opt,name=BuyerMail" json:"Buyer_Mail,omitempty"`
BuyerMemo string `protobuf:"bytes,10,opt,name=BuyerMemo" json:"Buyer_Memo,omitempty"`
CardNo string `protobuf:"bytes,11,opt,name=CardNo" json:"CardNo,omitempty"`
ExpireDate string `protobuf:"bytes,12,opt,name=ExpireDate" json:"ExpireDate,omitempty"`
CVV string `protobuf:"bytes,13,opt,name=CVV" json:"CVV,omitempty"`
TransMode string `protobuf:"bytes,14,opt,name=TransMode" json:"TransMode,omitempty"`
Installment string `protobuf:"bytes,15,opt,name=Installment" json:"Installment,omitempty"`
ReturnURL string `protobuf:"bytes,16,opt,name=ReturnURL" json:"Return_url,omitempty"`
CallbackURL string `protobuf:"bytes,17,opt,name=CallbackURL" json:"Callback_Url,omitempty"`
EReturn string `protobuf:"bytes,18,opt,name=EReturn" json:"e_return,omitempty"`
StrCheck string `protobuf:"bytes,19,opt,name=StrCheck" json:"Str_Check,omitempty"`
}
func (m *CreditCard) Reset() { *m = CreditCard{} }
func (m *CreditCard) String() string { return proto.CompactTextString(m) }
func (*CreditCard) ProtoMessage() {}
func (*CreditCard) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (m *CreditCard) GetSendType() string {
if m != nil {
return m.SendType
}
return ""
}
func (m *CreditCard) GetPayModeNo() string {
if m != nil {
return m.PayModeNo
}
return ""
}
func (m *CreditCard) GetCustomerId() string {
if m != nil {
return m.CustomerId
}
return ""
}
func (m *CreditCard) GetOrderNo() string {
if m != nil {
return m.OrderNo
}
return ""
}
func (m *CreditCard) GetAmount() string {
if m != nil {
return m.Amount
}
return ""
}
func (m *CreditCard) GetTransCode() string {
if m != nil {
return m.TransCode
}
return ""
}
func (m *CreditCard) GetBuyerName() string {
if m != nil {
return m.BuyerName
}
return ""
}
func (m *CreditCard) GetBuyerTelm() string {
if m != nil {
return m.BuyerTelm
}
return ""
}
func (m *CreditCard) GetBuyerMail() string {
if m != nil {
return m.BuyerMail
}
return ""
}
func (m *CreditCard) GetBuyerMemo() string {
if m != nil {
return m.BuyerMemo
}
return ""
}
func (m *CreditCard) GetCardNo() string {
if m != nil {
return m.CardNo
}
return ""
}
func (m *CreditCard) GetExpireDate() string {
if m != nil {
return m.ExpireDate
}
return ""
}
func (m *CreditCard) GetCVV() string {
if m != nil {
return m.CVV
}
return ""
}
func (m *CreditCard) GetTransMode() string {
if m != nil {
return m.TransMode
}
return ""
}
func (m *CreditCard) GetInstallment() string {
if m != nil {
return m.Installment
}
return ""
}
func (m *CreditCard) GetReturnURL() string {
if m != nil {
return m.ReturnURL
}
return ""
}
func (m *CreditCard) GetCallbackURL() string {
if m != nil {
return m.CallbackURL
}
return ""
}
func (m *CreditCard) GetEReturn() string {
if m != nil {
return m.EReturn
}
return ""
}
func (m *CreditCard) GetStrCheck() string {
if m != nil {
return m.StrCheck
}
return ""
}
func init() {
proto.RegisterType((*CreditCard)(nil), "beans.CreditCard")
}
func init() { proto.RegisterFile("gomypay.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{
// 326 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x92, 0xcf, 0x4a, 0x03, 0x31,
0x10, 0x87, 0xa9, 0xfd, 0x9f, 0x5a, 0xad, 0x11, 0x64, 0x10, 0x91, 0xe2, 0xc9, 0x93, 0x17, 0x9f,
0x40, 0x63, 0x0f, 0x05, 0xbb, 0x4a, 0xad, 0xbd, 0xa7, 0xcd, 0xa0, 0xa5, 0x9b, 0x64, 0xc9, 0x66,
0xc1, 0x7d, 0x29, 0x9f, 0x51, 0x92, 0xac, 0xd9, 0xdc, 0xf6, 0xf7, 0x7d, 0x3b, 0x24, 0x93, 0x19,
0x32, 0xfd, 0xd2, 0xb2, 0x2e, 0x78, 0xfd, 0x50, 0x18, 0x6d, 0x35, 0xed, 0xef, 0x90, 0xab, 0xf2,
0xee, 0xb7, 0x47, 0x08, 0x33, 0x28, 0x0e, 0x96, 0x71, 0x23, 0xe8, 0x35, 0x19, 0x7d, 0xa0, 0x12,
0x9b, 0xba, 0x40, 0xe8, 0xcc, 0x3b, 0xf7, 0xe3, 0x75, 0xcc, 0xf4, 0x86, 0x8c, 0xdf, 0x79, 0xbd,
0xd2, 0x02, 0x33, 0x0d, 0x27, 0x5e, 0xb6, 0x80, 0xde, 0x12, 0xc2, 0xaa, 0xd2, 0x6a, 0x89, 0x66,
0x29, 0xa0, 0xeb, 0x75, 0x42, 0x28, 0x90, 0xe1, 0x9b, 0x11, 0x68, 0x32, 0x0d, 0x3d, 0x2f, 0xff,
0x23, 0xbd, 0x22, 0x83, 0x27, 0xa9, 0x2b, 0x65, 0xa1, 0xef, 0x45, 0x93, 0xdc, 0x79, 0x1b, 0xc3,
0x55, 0xc9, 0xb4, 0x40, 0x18, 0x84, 0xf3, 0x22, 0x70, 0xf6, 0xb9, 0xaa, 0xd1, 0x64, 0x5c, 0x22,
0x0c, 0x83, 0x8d, 0x20, 0xda, 0x0d, 0xe6, 0x12, 0x46, 0x89, 0x75, 0x20, 0xda, 0x15, 0x3f, 0xe4,
0x30, 0x4e, 0xac, 0x03, 0xad, 0x45, 0xa9, 0x81, 0xa4, 0x16, 0xa5, 0xbf, 0xad, 0x7b, 0xa9, 0x4c,
0xc3, 0x24, 0xdc, 0x36, 0x24, 0xd7, 0xff, 0xe2, 0xa7, 0x38, 0x18, 0x7c, 0xe1, 0x16, 0xe1, 0x34,
0xf4, 0xdf, 0x12, 0x3a, 0x23, 0x5d, 0xb6, 0xdd, 0xc2, 0xd4, 0x0b, 0xf7, 0x19, 0xfb, 0x73, 0x0f,
0x08, 0x67, 0x49, 0x7f, 0x0e, 0xd0, 0x39, 0x99, 0x2c, 0x55, 0x69, 0x79, 0x9e, 0x4b, 0x54, 0x16,
0xce, 0xbd, 0x4f, 0x91, 0xab, 0x5f, 0xa3, 0xad, 0x8c, 0xfa, 0x5c, 0xbf, 0xc2, 0x2c, 0xd4, 0x47,
0xe0, 0xea, 0x19, 0xcf, 0xf3, 0x1d, 0xdf, 0x1f, 0x9d, 0xbf, 0x08, 0xf5, 0x09, 0x72, 0x13, 0x59,
0x84, 0xff, 0x81, 0x86, 0x89, 0x34, 0xd1, 0x6f, 0x81, 0x35, 0xec, 0x1b, 0xf7, 0x47, 0xb8, 0x6c,
0xb6, 0xa0, 0xc9, 0xbb, 0x81, 0x5f, 0x9f, 0xc7, 0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xaa, 0x8b,
0x78, 0xde, 0x4f, 0x02, 0x00, 0x00,
}
syntax = "proto3";
package beans;
message CreditCard {
string SendType = 1; //`json:"Send_Type,omitempty"`
string PayModeNo = 2; //`json:"Pay_Mode_No,omitempty"`
string CustomerId = 3; //`json:"CustomerId,omitempty"`
string OrderNo = 4; //`json:"Order_No,omitempty"`
string Amount = 5; //`json:"Amount,omitempty"`
string TransCode = 6; //`json:"TransCode,omitempty"`
string BuyerName = 7; //`json:"Buyer_Name,omitempty"`
string BuyerTelm = 8; //`json:"Buyer_Telm,omitempty"`
string BuyerMail = 9; //`json:"Buyer_Mail,omitempty"`
string BuyerMemo = 10; //`json:"Buyer_Memo,omitempty"`
string CardNo = 11; //`json:"CardNo,omitempty"`
string ExpireDate = 12; //`json:"ExpireDate,omitempty"`
string CVV = 13; //`json:"CVV,omitempty"`
string TransMode = 14; //`json:"TransMode,omitempty"`
string Installment = 15; //`json:"Installment,omitempty"`
string ReturnURL = 16; //`json:"Return_url,omitempty"`
string CallbackURL = 17; //`json:"Callback_Url,omitempty"`
string EReturn = 18; //`json:"e_return,omitempty"`
string StrCheck = 19; //`json:"Str_Check,omitempty"`
}
\ No newline at end of file
...@@ -2,20 +2,6 @@ ...@@ -2,20 +2,6 @@
// source: punchclock.proto // source: punchclock.proto
// DO NOT EDIT! // DO NOT EDIT!
/*
Package beans is a generated protocol buffer package.
It is generated from these files:
punchclock.proto
redis.proto
sendMail.proto
It has these top-level messages:
Punchclock
TimeStruct
Redis
SendMail
*/
package beans package beans
import proto "github.com/golang/protobuf/proto" import proto "github.com/golang/protobuf/proto"
...@@ -27,12 +13,6 @@ var _ = proto.Marshal ...@@ -27,12 +13,6 @@ var _ = proto.Marshal
var _ = fmt.Errorf var _ = fmt.Errorf
var _ = math.Inf var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
type Punchclock struct { type Punchclock struct {
Begin *TimeStruct `protobuf:"bytes,7,opt,name=Begin" json:"begin"` Begin *TimeStruct `protobuf:"bytes,7,opt,name=Begin" json:"begin"`
End *TimeStruct `protobuf:"bytes,8,opt,name=End" json:"end"` End *TimeStruct `protobuf:"bytes,8,opt,name=End" json:"end"`
...@@ -41,7 +21,7 @@ type Punchclock struct { ...@@ -41,7 +21,7 @@ type Punchclock struct {
func (m *Punchclock) Reset() { *m = Punchclock{} } func (m *Punchclock) Reset() { *m = Punchclock{} }
func (m *Punchclock) String() string { return proto.CompactTextString(m) } func (m *Punchclock) String() string { return proto.CompactTextString(m) }
func (*Punchclock) ProtoMessage() {} func (*Punchclock) ProtoMessage() {}
func (*Punchclock) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } func (*Punchclock) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{0} }
func (m *Punchclock) GetBegin() *TimeStruct { func (m *Punchclock) GetBegin() *TimeStruct {
if m != nil { if m != nil {
...@@ -69,7 +49,7 @@ type TimeStruct struct { ...@@ -69,7 +49,7 @@ type TimeStruct struct {
func (m *TimeStruct) Reset() { *m = TimeStruct{} } func (m *TimeStruct) Reset() { *m = TimeStruct{} }
func (m *TimeStruct) String() string { return proto.CompactTextString(m) } func (m *TimeStruct) String() string { return proto.CompactTextString(m) }
func (*TimeStruct) ProtoMessage() {} func (*TimeStruct) ProtoMessage() {}
func (*TimeStruct) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } func (*TimeStruct) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{1} }
func (m *TimeStruct) GetYear() string { func (m *TimeStruct) GetYear() string {
if m != nil { if m != nil {
...@@ -118,9 +98,9 @@ func init() { ...@@ -118,9 +98,9 @@ func init() {
proto.RegisterType((*TimeStruct)(nil), "beans.TimeStruct") proto.RegisterType((*TimeStruct)(nil), "beans.TimeStruct")
} }
func init() { proto.RegisterFile("punchclock.proto", fileDescriptor0) } func init() { proto.RegisterFile("punchclock.proto", fileDescriptor1) }
var fileDescriptor0 = []byte{ var fileDescriptor1 = []byte{
// 200 bytes of a gzipped FileDescriptorProto // 200 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x28, 0x28, 0xcd, 0x4b, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x28, 0x28, 0xcd, 0x4b,
0xce, 0x48, 0xce, 0xc9, 0x4f, 0xce, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x4d, 0x4a, 0xce, 0x48, 0xce, 0xc9, 0x4f, 0xce, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x4d, 0x4a,
......
...@@ -22,7 +22,7 @@ type Redis struct { ...@@ -22,7 +22,7 @@ type Redis struct {
func (m *Redis) Reset() { *m = Redis{} } func (m *Redis) Reset() { *m = Redis{} }
func (m *Redis) String() string { return proto.CompactTextString(m) } func (m *Redis) String() string { return proto.CompactTextString(m) }
func (*Redis) ProtoMessage() {} func (*Redis) ProtoMessage() {}
func (*Redis) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{0} } func (*Redis) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{0} }
func (m *Redis) GetKey() string { func (m *Redis) GetKey() string {
if m != nil { if m != nil {
...@@ -49,9 +49,9 @@ func init() { ...@@ -49,9 +49,9 @@ func init() {
proto.RegisterType((*Redis)(nil), "beans.Redis") proto.RegisterType((*Redis)(nil), "beans.Redis")
} }
func init() { proto.RegisterFile("redis.proto", fileDescriptor1) } func init() { proto.RegisterFile("redis.proto", fileDescriptor2) }
var fileDescriptor1 = []byte{ var fileDescriptor2 = []byte{
// 100 bytes of a gzipped FileDescriptorProto // 100 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x2e, 0x4a, 0x4d, 0xc9, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x2e, 0x4a, 0x4d, 0xc9,
0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x4d, 0x4a, 0x4d, 0xcc, 0x2b, 0x56, 0x72, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x4d, 0x4a, 0x4d, 0xcc, 0x2b, 0x56, 0x72,
......
...@@ -23,7 +23,7 @@ type SendMail struct { ...@@ -23,7 +23,7 @@ type SendMail struct {
func (m *SendMail) Reset() { *m = SendMail{} } func (m *SendMail) Reset() { *m = SendMail{} }
func (m *SendMail) String() string { return proto.CompactTextString(m) } func (m *SendMail) String() string { return proto.CompactTextString(m) }
func (*SendMail) ProtoMessage() {} func (*SendMail) ProtoMessage() {}
func (*SendMail) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{0} } func (*SendMail) Descriptor() ([]byte, []int) { return fileDescriptor3, []int{0} }
func (m *SendMail) GetTo() string { func (m *SendMail) GetTo() string {
if m != nil { if m != nil {
...@@ -57,9 +57,9 @@ func init() { ...@@ -57,9 +57,9 @@ func init() {
proto.RegisterType((*SendMail)(nil), "beans.SendMail") proto.RegisterType((*SendMail)(nil), "beans.SendMail")
} }
func init() { proto.RegisterFile("sendMail.proto", fileDescriptor2) } func init() { proto.RegisterFile("sendMail.proto", fileDescriptor3) }
var fileDescriptor2 = []byte{ var fileDescriptor3 = []byte{
// 116 bytes of a gzipped FileDescriptorProto // 116 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x2b, 0x4e, 0xcd, 0x4b, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x2b, 0x4e, 0xcd, 0x4b,
0xf1, 0x4d, 0xcc, 0xcc, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x4d, 0x4a, 0x4d, 0xcc, 0xf1, 0x4d, 0xcc, 0xcc, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x4d, 0x4a, 0x4d, 0xcc,
......
package controllers
import (
"encoding/json"
"log"
"net/http"
"github.com/gin-gonic/gin"
"github.com/teed7334-restore/homekeeper/base"
"github.com/teed7334-restore/homekeeper/beans"
"github.com/teed7334-restore/homekeeper/env"
)
//PayCreditCard 使用信用卡付款
func PayCreditCard(c *gin.Context) {
cfg := env.GetEnv()
params := getCreditCardParams(c)
params.CustomerId = cfg.GoMyPay.CustomerID
jsonStr, _ := json.Marshal(params)
jsonByte := []byte(jsonStr)
url := cfg.GoMyPay.URL
jsonByte = base.PostURL(url, jsonByte)
c.JSON(http.StatusOK, jsonByte)
}
//getCreditCardParams 取得HTTP POST帶過來之參數
func getCreditCardParams(c *gin.Context) *beans.CreditCard {
params := &beans.CreditCard{}
err := c.BindJSON(params)
if err != nil {
log.Println(err)
}
return params
}
...@@ -28,5 +28,6 @@ func API() *gin.Engine { ...@@ -28,5 +28,6 @@ func API() *gin.Engine {
route.POST("/Redis/LRange", controllers.LRangeRedis) route.POST("/Redis/LRange", controllers.LRangeRedis)
route.POST("/PunchClock/CalcTime", controllers.CalcTime) route.POST("/PunchClock/CalcTime", controllers.CalcTime)
route.POST("/PunchClock/ResetAllUseMinute", controllers.ResetAllUseMinute) route.POST("/PunchClock/ResetAllUseMinute", controllers.ResetAllUseMinute)
route.POST("/GoMyPay/PayCreditCard", controllers.PayCreditCard)
return route return route
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment